:muro:
package myframe;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import com.borland.jbcl.layout.*;
public class PolyLabDialog extends JDialog implements ItemListener{
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
GridLayout gridLayout1 = new GridLayout();
JPanel jPane1 = new JPanel();
JLabel jLabel1 = new JLabel();
JLabel jLabel111 = new JLabel();
JLabel XLabel8 = new JLabel();
JLabel jLabel6 = new JLabel();
JPanel jPane3 = new JPanel();
JLabel jLabel7 = new JLabel();
JTextField Y2Field = new JTextField(4);
JTextField X2Field = new JTextField(4);
FlowLayout flowLayout11 = new FlowLayout();
JLabel jLabel110 = new JLabel();
FlowLayout flowLayout12 = new FlowLayout();
JTextField Y1Field = new JTextField(4);
JLabel jLabel113 = new JLabel();
JPanel jPane2 = new JPanel();
JLabel jLabel5 = new JLabel();
JLabel jLabel4 = new JLabel();
JLabel XLabel9 = new JLabel();
JLabel jLabel112 = new JLabel();
JTextField X1Field = new JTextField(4);
JTextField Y3Field = new JTextField(4);
JLabel jLabel18 = new JLabel();
JLabel jLabel21 = new JLabel();
JLabel jLabel20 = new JLabel();
JLabel XLabel7 = new JLabel();
JLabel jLabel19 = new JLabel();
FlowLayout flowLayout10 = new FlowLayout();
JTextField X3Field = new JTextField(4);
JPanel jPane4 = new JPanel();
JLabel XLabel4 = new JLabel();
FlowLayout flowLayout7 = new FlowLayout();
JPanel jPane7 = new JPanel();
JLabel jLabel26 = new JLabel();
JLabel jLabel12 = new JLabel();
JLabel jLabel13 = new JLabel();
JTextField Y6Field = new JTextField(4);
JTextField X6Field = new JTextField(4);
JLabel jLabel27 = new JLabel();
JLabel jLabel23 = new JLabel();
JLabel jLabel16 = new JLabel();
JLabel jLabel17 = new JLabel();
JLabel XLabel6 = new JLabel();
FlowLayout flowLayout9 = new FlowLayout();
JTextField Y4Field = new JTextField(4);
JTextField X4Field = new JTextField(4);
JPanel jPane5 = new JPanel();
JLabel jLabel22 = new JLabel();
JLabel XLabel5 = new JLabel();
JLabel jLabel14 = new JLabel();
FlowLayout flowLayout8 = new FlowLayout();
JTextField X5Field = new JTextField(4);
JPanel jPane6 = new JPanel();
JLabel jLabel24 = new JLabel();
JTextField Y5Field = new JTextField(4);
JLabel jLabel25 = new JLabel();
JLabel jLabel15 = new JLabel();
JTextField Y7Field = new JTextField(4);
JTextField X7Field = new JTextField(4);
JLabel jLabel29 = new JLabel();
JPanel jPane8 = new JPanel();
JLabel XLabel = new JLabel();
JLabel jLabel3 = new JLabel();
JLabel jLabel2 = new JLabel();
FlowLayout flowLayout1 = new FlowLayout();
JLabel jLabel28 = new JLabel();
FlowLayout flowLayout6 = new FlowLayout();
JLabel XLabel3 = new JLabel();
JTextField X8Field = new JTextField(4);
JTextField Y8Field = new JTextField(4);
JLabel jLabel30 = new JLabel();
JLabel jLabel11 = new JLabel();
JPanel jPane9 = new JPanel();
JLabel jLabel31 = new JLabel();
JLabel jLabel10 = new JLabel();
FlowLayout flowLayout5 = new FlowLayout();
JTextField X9Field = new JTextField(4);
JLabel jLabel9 = new JLabel();
JLabel jLabel8 = new JLabel();
JLabel jLabel33 = new JLabel();
JLabel jLabel32 = new JLabel();
JLabel XLabel2 = new JLabel();
JTextField Y9Field = new JTextField(4);
JPanel jPane10 = new JPanel();
FlowLayout flowLayout2 = new FlowLayout();
JButton okButton = new JButton();
JPanel jPane11 = new JPanel();
JButton jButton1 = new JButton();
GridLayout gridLayout2 = new GridLayout();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JPanel jPanel6 = new JPanel();
BorderLayout borderLayout3 = new BorderLayout();
JPanel comboPanel = new JPanel();
JPanel jPanel8 = new JPanel();
JPanel jPanel9 = new JPanel();
JPanel jPanel10 = new JPanel();
JPanel jPanel11 = new JPanel();
JLabel jLabel34 = new JLabel();
Color mycolor = new Color(146,217,216);
private int numLati;
Vector vetVertici = new Vector();
Vector vetVerticiX = new Vector();
Vector vetVerticiY = new Vector();
JComboBox latiCombo;
Vector combo = new Vector();
//MyLanguage ml = new MyLanguage();
private FillPanel fpanel;
private ClipPanel cpanel;
private polyClipPanel pcpanel;
BorderLayout borderLayout4 = new BorderLayout();
JPanel jPanel7 = new JPanel();
JPanel jPanel12 = new JPanel();
JPanel jPanel13 = new JPanel();
JPanel jPanel14 = new JPanel();
JPanel jPanel15 = new JPanel();
JButton lavagnaButton = new JButton();
FlowLayout flowLayout3 = new FlowLayout();
public boolean fp=false;
public boolean cp=false;
public boolean pcp=false;
public PolyLabDialog(FillPanel panel,JFrame parent) {
super(parent,true);
this.fpanel=panel;
this.numLati=3;
fp=true;
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public PolyLabDialog(ClipPanel panel,JFrame parent) {
super(parent,true);
this.cpanel=panel;
this.numLati=1;
cp=true;
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
public PolyLabDialog(polyClipPanel panel,JFrame parent) {
super(parent,true);
this.pcpanel=panel;
this.numLati=3;
pcp=true;
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(borderLayout2);
jPanel1.setPreferredSize(new Dimension(344,444));
jPanel2.setPreferredSize(new Dimension(100, 10));
jPanel2.setLayout(gridLayout2);
jPanel3.setLayout(gridLayout1);
gridLayout1.setColumns(1);
gridLayout1.setRows(11);
jPane1.setBackground(mycolor);
jPane1.setPreferredSize(new Dimension(240, 40));
jLabel1.setFont(new java.awt.Font("Comic Sans MS", 3, 14));
jLabel1.setForeground(Color.blue);
jLabel1.setBorder(BorderFactory.createEtchedBorder());
jLabel1.setDebugGraphicsOptions(0);
jLabel1.setMaximumSize(new Dimension(150, 30));
jLabel1.setPreferredSize(new Dimension(150, 30));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel1.setText("Inserimento Vertici");
jLabel111.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel111.setForeground(Color.red);
jLabel111.setHorizontalAlignment(SwingConstants.CENTER);
jLabel111.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel111.setText("Y: ");
XLabel8.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel8.setForeground(Color.blue);
XLabel8.setHorizontalAlignment(SwingConstants.CENTER);
XLabel8.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel8.setText("X:");
jLabel6.setBackground(mycolor);
jLabel6.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel6.setPreferredSize(new Dimension(43, 15));
jLabel6.setText("2)");
jPane3.setBackground(mycolor);
jPane3.setPreferredSize(new Dimension(240, 30));
jPane3.setLayout(flowLayout11);
jLabel7.setText(" ");
Y2Field.setForeground(Color.blue);
Y2Field.setPreferredSize(new Dimension(43, 20));
Y2Field.setText("");
Y2Field.setHorizontalAlignment(SwingConstants.CENTER);
X2Field.setForeground(Color.blue);
X2Field.setText("");
X2Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel110.setPreferredSize(new Dimension(43, 20));
jLabel110.setText("");
Y1Field.setForeground(Color.blue);
Y1Field.setPreferredSize(new Dimension(43, 20));
Y1Field.setText("");
Y1Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel113.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel113.setForeground(Color.red);
jLabel113.setHorizontalAlignment(SwingConstants.CENTER);
jLabel113.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel113.setText("Y: ");
jPane2.setBackground(mycolor);
jPane2.setPreferredSize(new Dimension(240, 30));
jPane2.setLayout(flowLayout12);
jLabel5.setText(" ");
jLabel4.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel4.setText("1) ");
XLabel9.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel9.setForeground(Color.blue);
XLabel9.setHorizontalAlignment(SwingConstants.CENTER);
XLabel9.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel9.setText("X:");
jLabel112.setPreferredSize(new Dimension(43, 20));
jLabel112.setText("");
X1Field.setForeground(Color.blue);
X1Field.setText("");
X1Field.setHorizontalAlignment(SwingConstants.CENTER);
Y3Field.setForeground(Color.blue);
Y3Field.setPreferredSize(new Dimension(43, 20));
Y3Field.setText("");
Y3Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel18.setPreferredSize(new Dimension(43, 20));
jLabel18.setText("");
jLabel21.setText(" ");
jLabel20.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel20.setPreferredSize(new Dimension(43, 15));
jLabel20.setText("3) ");
XLabel7.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel7.setForeground(Color.blue);
XLabel7.setHorizontalAlignment(SwingConstants.CENTER);
XLabel7.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel7.setText("X:");
jLabel19.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel19.setForeground(Color.red);
jLabel19.setHorizontalAlignment(SwingConstants.CENTER);
jLabel19.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel19.setText("Y: ");
X3Field.setForeground(Color.blue);
X3Field.setText("");
X3Field.setHorizontalAlignment(SwingConstants.CENTER);
jPane4.setBackground(mycolor);
jPane4.setPreferredSize(new Dimension(240, 30));
jPane4.setLayout(flowLayout10);
XLabel4.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel4.setForeground(Color.blue);
XLabel4.setHorizontalAlignment(SwingConstants.CENTER);
XLabel4.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel4.setText("X:");
jPane7.setBackground(mycolor);
jPane7.setPreferredSize(new Dimension(240, 30));
jPane7.setLayout(flowLayout7);
jLabel26.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel26.setPreferredSize(new Dimension(43, 15));
jLabel26.setText("6)");
jLabel12.setPreferredSize(new Dimension(43, 20));
jLabel12.setText("");
jLabel13.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel13.setForeground(Color.red);
jLabel13.setHorizontalAlignment(SwingConstants.CENTER);
jLabel13.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel13.setText("Y: ");
Y6Field.setForeground(Color.blue);
Y6Field.setPreferredSize(new Dimension(43, 20));
Y6Field.setText("");
Y6Field.setHorizontalAlignment(SwingConstants.CENTER);
X6Field.setForeground(Color.blue);
X6Field.setText("");
X6Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel27.setText(" ");
jLabel23.setText(" ");
jLabel16.setPreferredSize(new Dimension(43, 20));
jLabel16.setText("");
jLabel17.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel17.setForeground(Color.red);
jLabel17.setHorizontalAlignment(SwingConstants.CENTER);
jLabel17.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel17.setText("Y: ");
XLabel6.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel6.setForeground(Color.blue);
XLabel6.setHorizontalAlignment(SwingConstants.CENTER);
XLabel6.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel6.setText("X:");
Y4Field.setForeground(Color.blue);
Y4Field.setPreferredSize(new Dimension(43, 20));
Y4Field.setText("");
Y4Field.setHorizontalAlignment(SwingConstants.CENTER);
X4Field.setForeground(Color.blue);
X4Field.setText("");
X4Field.setHorizontalAlignment(SwingConstants.CENTER);
jPane5.setBackground(mycolor);
jPane5.setPreferredSize(new Dimension(240, 30));
jPane5.setLayout(flowLayout9);
jLabel22.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel22.setPreferredSize(new Dimension(43, 15));
jLabel22.setText("4)");
XLabel5.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel5.setForeground(Color.blue);
XLabel5.setHorizontalAlignment(SwingConstants.CENTER);
XLabel5.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel5.setText("X:");
jLabel14.setPreferredSize(new Dimension(43, 20));
jLabel14.setText("");
X5Field.setForeground(Color.blue);
X5Field.setText("");
X5Field.setHorizontalAlignment(SwingConstants.CENTER);
jPane6.setBackground(mycolor);
jPane6.setPreferredSize(new Dimension(240, 30));
jPane6.setLayout(flowLayout8);
jLabel24.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel24.setPreferredSize(new Dimension(43, 15));
jLabel24.setText("5)");
Y5Field.setForeground(Color.blue);
Y5Field.setPreferredSize(new Dimension(43, 20));
Y5Field.setText("");
Y5Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel25.setText(" ");
jLabel15.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel15.setForeground(Color.red);
jLabel15.setHorizontalAlignment(SwingConstants.CENTER);
jLabel15.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel15.setText("Y: ");
Y7Field.setForeground(Color.blue);
Y7Field.setPreferredSize(new Dimension(43, 20));
Y7Field.setText("");
Y7Field.setHorizontalAlignment(SwingConstants.CENTER);
X7Field.setForeground(Color.blue);
X7Field.setText("");
X7Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel29.setText(" ");
jPane8.setLayout(flowLayout1);
jPane8.setBackground(mycolor);
jPane8.setPreferredSize(new Dimension(240, 30));
XLabel.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel.setForeground(Color.blue);
XLabel.setHorizontalAlignment(SwingConstants.CENTER);
XLabel.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel.setText("X:");
jLabel3.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel3.setForeground(Color.red);
jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel3.setText("Y: ");
jLabel2.setPreferredSize(new Dimension(43, 20));
jLabel2.setText("");
jLabel28.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel28.setPreferredSize(new Dimension(43, 15));
jLabel28.setText("7)");
XLabel3.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel3.setForeground(Color.blue);
XLabel3.setHorizontalAlignment(SwingConstants.CENTER);
XLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel3.setText("X:");
X8Field.setForeground(Color.blue);
X8Field.setText("");
X8Field.setHorizontalAlignment(SwingConstants.CENTER);
Y8Field.setForeground(Color.blue);
Y8Field.setPreferredSize(new Dimension(43, 20));
Y8Field.setText("");
Y8Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel30.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel30.setPreferredSize(new Dimension(43, 15));
jLabel30.setText("8)");
jLabel11.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel11.setForeground(Color.red);
jLabel11.setHorizontalAlignment(SwingConstants.CENTER);
jLabel11.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel11.setText("Y: ");
jPane9.setBackground(mycolor);
jPane9.setPreferredSize(new Dimension(240, 30));
jPane9.setLayout(flowLayout6);
jLabel31.setText(" ");
jLabel10.setPreferredSize(new Dimension(43, 20));
jLabel10.setText("");
X9Field.setForeground(Color.blue);
X9Field.setText("");
X9Field.setHorizontalAlignment(SwingConstants.CENTER);
jLabel9.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel9.setForeground(Color.red);
jLabel9.setHorizontalAlignment(SwingConstants.CENTER);
jLabel9.setHorizontalTextPosition(SwingConstants.CENTER);
jLabel9.setText("Y: ");
jLabel8.setPreferredSize(new Dimension(43, 20));
jLabel8.setText("");
jLabel33.setText(" ");
jLabel32.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel32.setPreferredSize(new Dimension(43, 15));
jLabel32.setText("9)");
XLabel2.setFont(new java.awt.Font("Dialog", 1, 11));
XLabel2.setForeground(Color.blue);
XLabel2.setHorizontalAlignment(SwingConstants.CENTER);
XLabel2.setHorizontalTextPosition(SwingConstants.CENTER);
XLabel2.setText("X:");
Y9Field.setForeground(Color.blue);
Y9Field.setPreferredSize(new Dimension(43, 20));
Y9Field.setText("");
Y9Field.setHorizontalAlignment(SwingConstants.CENTER);
jPane10.setBackground(mycolor);
jPane10.setPreferredSize(new Dimension(240, 30));
jPane10.setLayout(flowLayout5);
okButton.setBackground(SystemColor.desktop);
okButton.setFont(new java.awt.Font("Dialog", 3, 11));
okButton.setForeground(Color.yellow);
okButton.setBorder(BorderFactory.createRaisedBevelBorder());
okButton.setMaximumSize(new Dimension(60, 19));
okButton.setPreferredSize(new Dimension(40, 25));
okButton.setText("OK");
okButton.addActionListener(new PolyLabDialog_okButton_actionAdapter(this));
jPane11.setLayout(flowLayout2);
jPane11.setBackground(mycolor);
jPane11.setPreferredSize(new Dimension(240, 35));
jButton1.setBackground(SystemColor.desktop);
jButton1.setFont(new java.awt.Font("Dialog", 3, 11));
jButton1.setForeground(Color.yellow);
jButton1.setBorder(BorderFactory.createRaisedBevelBorder());
jButton1.setPreferredSize(new Dimension(55, 25));
jButton1.setVerifyInputWhenFocusTarget(true);
jButton1.setText("Annulla");
jButton1.addActionListener(new PolyLabDialog_jButton1_actionAdapter(this));
gridLayout2.setColumns(1);
gridLayout2.setRows(3);
jPanel5.setLayout(borderLayout3);
jPanel11.setBackground(mycolor);
jPanel11.setPreferredSize(new Dimension(10, 30));
jPanel8.setBackground(mycolor);
jPanel8.setPreferredSize(new Dimension(10, 40));
jLabel34.setFont(new java.awt.Font("Dialog", 3, 11));
jLabel34.setForeground(SystemColor.desktop);
jLabel34.setText("N° lati:");
comboPanel.setBackground(mycolor);
comboPanel.setBorder(BorderFactory.createEtchedBorder());
jPanel3.setBackground(mycolor);
jPanel3.setBorder(BorderFactory.createEtchedBorder());
jPanel4.setBackground(mycolor);
jPanel10.setBackground(mycolor);
jPanel9.setBackground(mycolor);
jPanel6.setBackground(mycolor);
jPanel6.setLayout(borderLayout4);
jPanel15.setBackground(mycolor);
jPanel15.setPreferredSize(new Dimension(10, 40));
jPanel7.setBackground(mycolor);
jPanel7.setPreferredSize(new Dimension(10, 65));
jPanel14.setBackground(mycolor);
jPanel13.setBackground(mycolor);
jPanel12.setBackground(mycolor);
jPanel12.setBorder(BorderFactory.createEtchedBorder());
jPanel12.setLayout(flowLayout3);
lavagnaButton.setBackground(SystemColor.desktop);
lavagnaButton.setFont(new java.awt.Font("Dialog", 1, 11));
lavagnaButton.setForeground(SystemColor.activeCaptionText);
lavagnaButton.setBorder(BorderFactory.createRaisedBevelBorder());
lavagnaButton.setDebugGraphicsOptions(0);
lavagnaButton.setPreferredSize(new Dimension(53, 22));
lavagnaButton.setActionCommand("lavagnaButton");
lavagnaButton.setHorizontalTextPosition(SwingConstants.CENTER);
lavagnaButton.setText("Lavagna");
lavagnaButton.addActionListener(new MyLavagnaListener(this));
this.setTitle(ml.str41);
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jPanel2, BorderLayout.WEST);
jPanel2.add(jPanel4, null);
jPanel2.add(jPanel5, null);
jPanel5.add(comboPanel, BorderLayout.CENTER);
comboPanel.add(jLabel34, null);
jPanel5.add(jPanel8, BorderLayout.SOUTH);
jPanel5.add(jPanel9, BorderLayout.WEST);
jPanel5.add(jPanel10, BorderLayout.EAST);
jPanel5.add(jPanel11, BorderLayout.NORTH);
jPanel2.add(jPanel6, null);
jPanel6.add(jPanel7, BorderLayout.SOUTH);
jPanel6.add(jPanel12, BorderLayout.CENTER);
jPanel12.add(lavagnaButton, null);
jPanel6.add(jPanel13, BorderLayout.WEST);
jPanel6.add(jPanel14, BorderLayout.EAST);
jPanel6.add(jPanel15, BorderLayout.NORTH);
jPanel1.add(jPanel3, BorderLayout.CENTER);
jPanel3.add(jPane1, null);
jPane1.add(jLabel1, null);
jPanel3.add(jPane2, null);
jPanel3.add(jPane3, null);
jPanel3.add(jPane4, null);
jPanel3.add(jPane5, null);
jPanel3.add(jPane6, null);
jPanel3.add(jPane7, null);
jPanel3.add(jPane8, null);
jPanel3.add(jPane9, null);
jPanel3.add(jPane10, null);
jPanel3.add(jPane11, null);
jPane11.add(jButton1, null);
jPane11.add(okButton, null);
jPane10.add(jLabel32, null);
jPane10.add(XLabel2, null);
jPane10.add(X9Field, null);
jPane10.add(jLabel8, null);
jPane10.add(jLabel9, null);
jPane10.add(Y9Field, null);
jPane10.add(jLabel33, null);
jPane9.add(jLabel30, null);
jPane9.add(XLabel3, null);
jPane9.add(X8Field, null);
jPane9.add(jLabel10, null);
jPane9.add(jLabel11, null);
jPane9.add(Y8Field, null);
jPane9.add(jLabel31, null);
jPane8.add(jLabel28, null);
jPane8.add(XLabel, null);
jPane8.add(X7Field, null);
jPane8.add(jLabel2, null);
jPane8.add(jLabel3, null);
jPane8.add(Y7Field, null);
jPane8.add(jLabel29, null);
jPane6.add(jLabel24, null);
jPane6.add(XLabel5, null);
jPane6.add(X5Field, null);
jPane6.add(jLabel14, null);
jPane6.add(jLabel15, null);
jPane6.add(Y5Field, null);
jPane6.add(jLabel25, null);
jPane5.add(jLabel22, null);
jPane5.add(XLabel6, null);
jPane5.add(X4Field, null);
jPane5.add(jLabel16, null);
jPane5.add(jLabel17, null);
jPane5.add(Y4Field, null);
jPane5.add(jLabel23, null);
jPane7.add(jLabel26, null);
jPane7.add(XLabel4, null);
jPane7.add(X6Field, null);
jPane7.add(jLabel12, null);
jPane7.add(jLabel13, null);
jPane7.add(Y6Field, null);
jPane7.add(jLabel27, null);
jPane4.add(jLabel20, null);
jPane4.add(XLabel7, null);
jPane4.add(X3Field, null);
jPane4.add(jLabel18, null);
jPane4.add(jLabel19, null);
jPane4.add(Y3Field, null);
jPane4.add(jLabel21, null);
jPane2.add(jLabel4, null);
jPane2.add(XLabel9, null);
jPane2.add(X1Field, null);
jPane2.add(jLabel112, null);
jPane2.add(jLabel113, null);
jPane2.add(Y1Field, null);
jPane2.add(jLabel5, null);
jPane3.add(jLabel6, null);
jPane3.add(XLabel8, null);
jPane3.add(X2Field, null);
jPane3.add(jLabel110, null);
jPane3.add(jLabel111, null);
jPane3.add(Y2Field, null);
jPane3.add(jLabel7, null);
combo.add(ml.str65);
combo.add(ml.str66);
combo.add(ml.str67);
combo.add(ml.str68);
combo.add(ml.str69);
combo.add(ml.str70);
combo.add(ml.str71);
latiCombo = new JComboBox(combo);
latiCombo.setPreferredSize(new Dimension(60, 20));
latiCombo.addItemListener(this);
comboPanel.add(latiCombo);
/* CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
CancellaTxt(9);*/
BloccaTxt(9);
BloccaTxt(8);
BloccaTxt(7);
BloccaTxt(6);
BloccaTxt(5);
BloccaTxt(4);
this.setSize(new Dimension(450,450));
this.show();
}
public void itemStateChanged(ItemEvent ei) {
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
CancellaTxt(9);
numLati=3;
if(ei.getItem().equals(combo.get(0))){
numLati=3;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
BloccaTxt(9);
BloccaTxt(8);
BloccaTxt(7);
BloccaTxt(6);
BloccaTxt(5);
BloccaTxt(4);
}
else if(ei.getItem().equals(combo.get(1))){
numLati=4;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
BloccaTxt(9);
BloccaTxt(8);
BloccaTxt(7);
BloccaTxt(6);
BloccaTxt(5);
AttivaTxt(4);
}
else if(ei.getItem().equals(combo.get(2))){
numLati=5;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
BloccaTxt(9);
BloccaTxt(8);
BloccaTxt(7);
BloccaTxt(6);
AttivaTxt(5);
AttivaTxt(4);
}
else if(ei.getItem().equals(combo.get(3))){
numLati=6;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
BloccaTxt(9);
BloccaTxt(8);
BloccaTxt(7);
AttivaTxt(6);
AttivaTxt(5);
AttivaTxt(4);
}
else if(ei.getItem().equals(combo.get(4))){
numLati=7;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
BloccaTxt(9);
BloccaTxt(8);
AttivaTxt(7);
AttivaTxt(6);
AttivaTxt(5);
AttivaTxt(4);
}
else if(ei.getItem().equals(combo.get(5))){
numLati=8;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
BloccaTxt(9);
AttivaTxt(8);
AttivaTxt(7);
AttivaTxt(6);
AttivaTxt(5);
AttivaTxt(4);
}
else if(ei.getItem().equals(combo.get(6))){
numLati=9;
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
CancellaTxt(9);
AttivaTxt(9);
AttivaTxt(8);
AttivaTxt(7);
AttivaTxt(6);
AttivaTxt(5);
AttivaTxt(4);
}
}
private int getLNLatiT(){
return numLati;
}
private void BloccaTxt(int n) {
switch (n) {
case 1:
X1Field.setEditable(false);
Y1Field.setEditable(false);
break;
case 2:
X2Field.setEditable(false);
Y2Field.setEditable(false);
break;
case 3:
X3Field.setEditable(false);
Y3Field.setEditable(false);
break;
case 4:
X4Field.setEditable(false);
Y4Field.setEditable(false);
break;
case 5:
X5Field.setEditable(false);
Y5Field.setEditable(false);
break;
case 6:
X6Field.setEditable(false);
Y6Field.setEditable(false);
break;
case 7:
X7Field.setEditable(false);
Y7Field.setEditable(false);
break;
case 8:
X8Field.setEditable(false);
Y8Field.setEditable(false);
break;
case 9:
X9Field.setEditable(false);
Y9Field.setEditable(false);
break;
}
}
private void AttivaTxt(int n) {
switch (n) {
case 1:
X1Field.setEditable(true);
Y1Field.setEditable(true);
break;
case 2:
X2Field.setEditable(true);
Y2Field.setEditable(true);
break;
case 3:
X3Field.setEditable(true);
Y3Field.setEditable(true);
break;
case 4:
X4Field.setEditable(true);
Y4Field.setEditable(true);
break;
case 5:
X5Field.setEditable(true);
Y5Field.setEditable(true);
break;
case 6:
X6Field.setEditable(true);
Y6Field.setEditable(true);
break;
case 7:
X7Field.setEditable(true);
Y7Field.setEditable(true);
break;
case 8:
X8Field.setEditable(true);
Y8Field.setEditable(true);
break;
case 9:
X9Field.setEditable(true);
Y9Field.setEditable(true);
break;
}
}
private void CancellaTxt(int n){
switch (n){
case 1:
X1Field.setText("");
Y1Field.setText("");
break;
case 2:
X2Field.setText("");
Y2Field.setText("");
break;
case 3:
X3Field.setText("");
Y3Field.setText("");
break;
case 4:
X4Field.setText("");
Y4Field.setText("");
break;
case 5:
X5Field.setText("");
Y5Field.setText("");
break;
case 6:
X6Field.setText("");
Y6Field.setText("");
break;
case 7:
X7Field.setText("");
Y7Field.setText("");
break;
case 8:
X8Field.setText("");
Y8Field.setText("");
break;
case 9:
X9Field.setText("");
Y9Field.setText("");
break;
}
}
public void setVertici(Vector vetX,Vector vetY){
int n = vetX.size();
switch(n){
case 3 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
break;
case 4 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
break;
case 5 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
X5Field.setText(vetX.get(4).toString());
Y5Field.setText(vetY.get(4).toString());
break;
case 6 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
X5Field.setText(vetX.get(4).toString());
Y5Field.setText(vetY.get(4).toString());
X6Field.setText(vetX.get(5).toString());
Y6Field.setText(vetY.get(5).toString());
break;
case 7 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
X5Field.setText(vetX.get(4).toString());
Y5Field.setText(vetY.get(4).toString());
X6Field.setText(vetX.get(5).toString());
Y6Field.setText(vetY.get(5).toString());
X7Field.setText(vetX.get(6).toString());
Y7Field.setText(vetY.get(6).toString());
break;
case 8 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
X5Field.setText(vetX.get(4).toString());
Y5Field.setText(vetY.get(4).toString());
X6Field.setText(vetX.get(5).toString());
Y6Field.setText(vetY.get(5).toString());
X7Field.setText(vetX.get(6).toString());
Y7Field.setText(vetY.get(6).toString());
X8Field.setText(vetX.get(7).toString());
Y8Field.setText(vetY.get(7).toString());
break;
case 9 :
X1Field.setText(vetX.get(0).toString());
Y1Field.setText(vetY.get(0).toString());
X2Field.setText(vetX.get(1).toString());
Y2Field.setText(vetY.get(1).toString());
X3Field.setText(vetX.get(2).toString());
Y3Field.setText(vetY.get(2).toString());
X4Field.setText(vetX.get(3).toString());
Y4Field.setText(vetY.get(3).toString());
X5Field.setText(vetX.get(4).toString());
Y5Field.setText(vetY.get(4).toString());
X6Field.setText(vetX.get(5).toString());
Y6Field.setText(vetY.get(5).toString());
X7Field.setText(vetX.get(6).toString());
Y7Field.setText(vetY.get(6).toString());
X8Field.setText(vetX.get(7).toString());
Y8Field.setText(vetY.get(7).toString());
X9Field.setText(vetX.get(8).toString());
Y9Field.setText(vetY.get(8).toString());
break;
default :
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
CancellaTxt(9);
}
}
public void OK(){
numLati=3;
vetVertici.clear();
vetVerticiX.clear();
vetVerticiY.clear();
try{
/*vertice 1*/
vetVertici.add(Integer.valueOf(X1Field.getText()));
vetVertici.add(Integer.valueOf(Y1Field.getText()));
vetVerticiX.add(Integer.valueOf(X1Field.getText()));
vetVerticiY.add(Integer.valueOf(Y1Field.getText()));
/*vertice 2*/
vetVertici.add(Integer.valueOf(X2Field.getText()));
vetVertici.add(Integer.valueOf(Y2Field.getText()));
vetVerticiX.add(Integer.valueOf(X2Field.getText()));
vetVerticiY.add(Integer.valueOf(Y2Field.getText()));
/*vertice 3*/
vetVertici.add(Integer.valueOf(X3Field.getText()));
vetVertici.add(Integer.valueOf(Y3Field.getText()));
vetVerticiX.add(Integer.valueOf(X3Field.getText()));
vetVerticiY.add(Integer.valueOf(Y3Field.getText()));
if (X4Field.isEditable()) { /*vertice 4*/
vetVertici.add(Integer.valueOf(X4Field.getText()));
vetVertici.add(Integer.valueOf(Y4Field.getText()));
vetVerticiX.add(Integer.valueOf(X4Field.getText()));
vetVerticiY.add(Integer.valueOf(Y4Field.getText()));
if (X5Field.isEditable()) { /*vertice 5*/
vetVertici.add(Integer.valueOf(X5Field.getText()));
vetVertici.add(Integer.valueOf(Y5Field.getText()));
vetVerticiX.add(Integer.valueOf(X5Field.getText()));
vetVerticiY.add(Integer.valueOf(Y5Field.getText()));
if (X6Field.isEditable()) { /*vertice 6*/
vetVertici.add(Integer.valueOf(X6Field.getText()));
vetVertici.add(Integer.valueOf(Y6Field.getText()));
vetVerticiX.add(Integer.valueOf(X6Field.getText()));
vetVerticiY.add(Integer.valueOf(Y6Field.getText()));
if (X7Field.isEditable()) { /*vertice 7*/
vetVertici.add(Integer.valueOf(X7Field.getText()));
vetVertici.add(Integer.valueOf(Y7Field.getText()));
vetVerticiX.add(Integer.valueOf(X7Field.getText()));
vetVerticiY.add(Integer.valueOf(Y7Field.getText()));
if (X8Field.isEditable()) { /*vertice 8*/
vetVertici.add(Integer.valueOf(X8Field.getText()));
vetVertici.add(Integer.valueOf(Y8Field.getText()));
vetVerticiX.add(Integer.valueOf(X8Field.getText()));
vetVerticiY.add(Integer.valueOf(Y8Field.getText()));
if (X9Field.isEditable()) { /*vertice 9*/
vetVertici.add(Integer.valueOf(X9Field.getText()));
vetVertici.add(Integer.valueOf(Y9Field.getText()));
vetVerticiX.add(Integer.valueOf(X9Field.getText()));
vetVerticiY.add(Integer.valueOf(Y9Field.getText()));
}
}
}
}
}
}
if(fp){
fpanel.setVerticiX(vetVerticiX);
fpanel.setVerticiY(vetVerticiY);
fpanel.setEdge();
}
else if(pcp){
pcpanel.setVerticiX(vetVerticiX);
pcpanel.setVerticiY(vetVerticiY);
}
else if(cp){
cpanel.setVerticiX(vetVerticiX);
cpanel.setVerticiY(vetVerticiY);
}
if (!ControllaDati.verificaVerticiDifferenti(vetVerticiX, vetVerticiY)) {
Toolkit.getDefaultToolkit().beep();
JOptionPane.showMessageDialog(this,
ml.str76, //76
this.getTitle(),
JOptionPane.ERROR_MESSAGE);
vetVertici.clear();
vetVerticiX.clear();
vetVerticiY.clear();
if(fp){
fpanel.verX.clear();
fpanel.verY.clear();
}
else if(pcp){
pcpanel.verX.clear();
pcpanel.verY.clear();
}
else if(cp){
cpanel.verX.clear();
cpanel.verY.clear();
}
CancellaTxt(1);
CancellaTxt(2);
CancellaTxt(3);
CancellaTxt(4);
CancellaTxt(5);
CancellaTxt(6);
CancellaTxt(7);
CancellaTxt(8);
CancellaTxt(9);
}
else {
numLati = vetVerticiX.size();
System.out.println("-- Numero lati = " + numLati); /*Test: */
if(fp)
chiudiFillPanel();
else if(pcp)
chiudipolyClipPanel();
}
}
catch(NumberFormatException e){
//System.out.println("Errore: Inserimento dati errati"); /* Test */
Toolkit.getDefaultToolkit().beep();
/*78*/ JOptionPane.showMessageDialog(this,ml.str78,this.getTitle(),JOptionPane.ERROR_MESSAGE);
vetVertici.clear();
vetVerticiX.clear();
vetVerticiY.clear();
}
}
private void chiudiFillPanel() {
fpanel.setIgnoreRepaint(true);
fpanel.setEnabled(true);
setVisible(false);
fpanel.setIgnoreRepaint(false);
fpanel.repaint();
}
private void chiudipolyClipPanel() {
pcpanel.setIgnoreRepaint(true);
pcpanel.setEnabled(true);
setVisible(false);
pcpanel.setIgnoreRepaint(false);
pcpanel.repaint();
}
private void copia(Vector v1, Vector v2){
v2.clear();
for(int i=0;i < v1.size() ; i++){
v2.add(v1.get(i));
}
}
private boolean verificaVerticiDifferenti( Vector vetX, Vector vetY ){
int k=vetX.size();
for(int i=0;i<(k-1);i++)
for(int j=(i+1);j<k;j++)
{
if(vetX.get(i).equals(vetX.get(j))&&vetY.get(i).equals(vetY.get(j)))
return false;
}
return true;
}
public Vector getVetVertici(){
return vetVertici;
}
public Vector getVetVerticiX(){
return vetVerticiX;
}
public Vector getVetVerticiY(){
return vetVerticiY;
}
public void Annulla(){
numLati=0;
if(fp)
chiudiFillPanel();
else if(pcp)
chiudipolyClipPanel();
}
void okButton_actionPerformed(ActionEvent e) {
this.OK();
if(fp)
fpanel.setFill();
else if(pcp)
pcpanel.setFill();
}
public void OpenLavagna(){
this.setEnabled(false);
javax.swing.SwingUtilities.invokeLater(new myOpenDrawer2D(this.getLNLatiT(),this));
}
void jButton1_actionPerformed(ActionEvent e) {
this.Annulla();
}
}
class MyLavagnaListener implements ActionListener{
private PolyLabDialog frame;
public MyLavagnaListener(PolyLabDialog tFrame){
frame = tFrame;
}
public void actionPerformed(ActionEvent evt)
{
if(evt.getActionCommand().equals("lavagnaButton")){
frame.OpenLavagna();
}
}
}
/*Nota: i vertici della figura vengono memorizzati nel vettore
vetVertici nell ordine:
x1, y1, x2, y2, x3, y3, ecc.
nei vettori vetVerticiX e vetVerticiY nel ordine
vetVerticiX = x1, x2, x3, ecc.
vetVerticiY = y1, y2, y3, ecc.
i controlli che vengono effettuati sono:
- che i valori immessi siano tutti validi ( solo numeri )
- che non vengano immessi vertici uguali ( tramite la funzione
verificaVerticiDifferenti)
La figura oltre ad essere descritta da i suoi vertici è caratterizzata anche dal
numero dei lati, memorizato nella variabile iNumeroLati che viene inizializzato
a zero e posto a zero in caso di errore.
18/05 deve essere inserito il controllo di non sequenzialità dei vertici grazie
alla funzione che mi da bizio
*/
class PolyLabDialog_okButton_actionAdapter implements java.awt.event.ActionListener {
PolyLabDialog adaptee;
PolyLabDialog_okButton_actionAdapter(PolyLabDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.okButton_actionPerformed(e);
}
}
class PolyLabDialog_jButton1_actionAdapter implements java.awt.event.ActionListener {
PolyLabDialog adaptee;
PolyLabDialog_jButton1_actionAdapter(PolyLabDialog adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}
Classe clipPanel
class ClipPanel extends JPanel implements ScreenListener{
//lo screen da disegnare
//dimensione in pizel di una cella dello screen
int size;
//dimensione orizzontale dello screen
int hSize;
//dimensione verticale dello screen
int vSize;
int x1,x2,y1,y2,x0clip,xfclip,y0clip,yfclip;
private Point selectedPoint=null;
private Point selectedPoint1=null;
private Point selectedPoint2=null;
boolean disretta=false;
boolean disClipBox=false;
Vector verX =new Vector();
Vector verY =new Vector();
String point1="";
String point2="";
boolean rettafuori=false;
public ClipPanel(){
setLayout(new BorderLayout());
size = 6;
hSize = 150;
vSize = 110;
setPreferredSize(new Dimension(size*hSize, size*vSize));
this.setBackground(Color.WHITE);
this.setVisible(true);
}
public void paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setColor(Color.BLUE);
if(disretta && !rettafuori){
g2.drawLine(x1, size * vSize - y1, x2, size * vSize - y2);
g2.drawString(point1,x1-40,size*vSize-y1+25);
g2.drawString(point2,x2+15,size*vSize-y2-15);
}
if(disClipBox){
g2.setColor(Color.RED);
g2.drawLine(x0clip,0,x0clip,size*vSize);
g2.drawLine(xfclip,0,xfclip,size*vSize);
g2.drawLine(0,size*vSize-yfclip,size*hSize,size*vSize-yfclip);
g2.drawLine(0,size*vSize-y0clip,size*hSize,size*vSize-y0clip);
}
}
public void setRetta(int x1,int y1,int x2,int y2){
point1="";
point2="";
disretta=true;
if(x1==-500 && x2==-500 && y1==-500 && y2==-500){
point1 = "";
point2 = "";
rettafuori=true;
}
else{
this.x1 = x1 * size;
this.x2 = x2 * size;
this.y1 = y1 * size;
this.y2 = y2 * size;
point1 += "(" + x1 + "," + y1 + ")";
point2 += "(" + x2 + "," + y2 + ")";
System.out.println("punti di clip;clipframe: p0:" + x1 + "," + y1 + "p1:" +
x2 + "," + y2);
repaint();
rettafuori=false;
}
}
public void setVerticiX(Vector v){
int lung=v.size();
for(int i=0;i<lung;i++)
verX.add(v.get(i));
}
public void setVerticiY(Vector v){
int lung=v.size();
for(int i=0;i<lung;i++)
verY.add(v.get(i));
}
public void setClipBox(int x1,int x2,int y1,int y2){
disClipBox=true;
this.x0clip=x1*size;
this.y0clip=y1*size;
this.xfclip=x2*size;
this.yfclip=y2*size;
repaint();
}
//questo metodo viene invocato dallo screen quando lo screen
//accende o spegne un pixel; il pannello quindi si ridisegna
//con repaint
public void screenChanged(Screen screen){
repaint();
};
}
public class ClipScelta extends JFrame {
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
GridLayout gridLayout1 = new GridLayout();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
Color mycolor = new Color(146, 217, 216);
BorderLayout borderLayout2 = new BorderLayout();
BorderLayout borderLayout3 = new BorderLayout();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JPanel jPanel6 = new JPanel();
JPanel jPanel7 = new JPanel();
JPanel jPanel8 = new JPanel();
JPanel jPanel9 = new JPanel();
JPanel jPanel10 = new JPanel();
JPanel jPanel11 = new JPanel();
JPanel jPanel12 = new JPanel();
JPanel jPanel13 = new JPanel();
JButton cyrusbutton = new JButton();
BorderLayout borderLayout4 = new BorderLayout();
JButton clipButton = new JButton();
BorderLayout borderLayout5 = new BorderLayout();
public ClipScelta() {
super("Clipping");
this.setExtendedState(NORMAL);
this.setResizable(false);
this.setSize(380,330);
try {
jbInit();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
void jbInit() throws Exception {
this.getContentPane().setLayout(borderLayout1);
jPanel1.setLayout(gridLayout1);
gridLayout1.setColumns(2);
gridLayout1.setRows(1);
jPanel2.setLayout(borderLayout2);
jPanel3.setLayout(borderLayout3);
jPanel8.setBackground(mycolor);
jPanel8.setMinimumSize(new Dimension(10, 10));
jPanel8.setPreferredSize(new Dimension(10, 115));
jPanel13.setBackground(mycolor);
jPanel13.setPreferredSize(new Dimension(10, 115));
jPanel11.setBackground(mycolor);
jPanel11.setPreferredSize(new Dimension(55, 10));
jPanel7.setBackground(mycolor);
jPanel7.setPreferredSize(new Dimension(55, 10));
jPanel12.setBackground(mycolor);
jPanel12.setPreferredSize(new Dimension(55, 10));
jPanel10.setBackground(mycolor);
jPanel10.setPreferredSize(new Dimension(10, 115));
jPanel5.setBackground(mycolor);
jPanel5.setPreferredSize(new Dimension(10, 115));
jPanel6.setBackground(mycolor);
jPanel6.setEnabled(true);
jPanel6.setPreferredSize(new Dimension(55, 10));
cyrusbutton.setFont(new java.awt.Font("Dialog", 1, 10));
cyrusbutton.setBorder(BorderFactory.createRaisedBevelBorder());
cyrusbutton.setPreferredSize(new Dimension(77, 60));
cyrusbutton.setToolTipText("Apre l\'ambiente di Clipping di Cyrus-Beck");
cyrusbutton.setHorizontalAlignment(SwingConstants.CENTER);
cyrusbutton.setHorizontalTextPosition(SwingConstants.CENTER);
cyrusbutton.setIcon(new ImageIcon(new java.net.URL("file:///C:/Documents and Settings/Gio cable/jbproject/Myframe/images/cirus.PNG")));
cyrusbutton.setText("");
cyrusbutton.addActionListener(new ClipScelta_cyrusbutton_actionAdapter(this));
jPanel4.setLayout(borderLayout4);
clipButton.setFont(new java.awt.Font("Dialog", 0, 10));
clipButton.setToolTipText("Apre l\'ambiente del Clipping dei Poligoni");
clipButton.setActionCommand("Clipping di poligoni");
clipButton.setHorizontalTextPosition(SwingConstants.CENTER);
clipButton.setIcon(new ImageIcon(new java.net.URL("file:///C:/Documents and Settings/Gio cable/jbproject/Myframe/images/clippol.PNG")));
clipButton.setText("");
clipButton.addActionListener(new ClipScelta_clipButton_actionAdapter(this));
jPanel9.setLayout(borderLayout5);
jPanel4.setBackground(Color.white);
jPanel9.setBackground(Color.white);
jPanel9.setAlignmentY((float) 0.5);
jPanel9.setBorder(BorderFactory.createRaisedBevelBorder());
this.getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.add(jPanel2, null);
jPanel2.add(jPanel4, BorderLayout.CENTER);
jPanel4.add(cyrusbutton, BorderLayout.CENTER);
jPanel2.add(jPanel5, BorderLayout.SOUTH);
jPanel2.add(jPanel6, BorderLayout.WEST);
jPanel2.add(jPanel7, BorderLayout.EAST);
jPanel2.add(jPanel8, BorderLayout.NORTH);
jPanel1.add(jPanel3, null);
jPanel3.add(jPanel9, BorderLayout.CENTER);
jPanel9.add(clipButton, BorderLayout.CENTER);
jPanel3.add(jPanel10, BorderLayout.SOUTH);
jPanel3.add(jPanel11, BorderLayout.WEST);
jPanel3.add(jPanel12, BorderLayout.EAST);
jPanel3.add(jPanel13, BorderLayout.NORTH);
this.show();
}
void cyrusbutton_actionPerformed(ActionEvent e) throws MalformedURLException {
new ClipFrame();
this.dispose();
}
void clipButton_actionPerformed(ActionEvent e) {
new PolygonClipFrame();
this.dispose();
}
}
class ClipScelta_cyrusbutton_actionAdapter implements java.awt.event.ActionListener {
ClipScelta adaptee;
ClipScelta_cyrusbutton_actionAdapter(ClipScelta adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
try {
adaptee.cyrusbutton_actionPerformed(e);
}
catch (MalformedURLException ex) {
}
}
}
class ClipScelta_clipButton_actionAdapter implements java.awt.event.ActionListener {
ClipScelta adaptee;
ClipScelta_clipButton_actionAdapter(ClipScelta adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.clipButton_actionPerformed(e);
}
}
public class ClipFrame extends JFrame implements ActionListener{
int size=6;
int hSize=900;
int vSize=600;
JButton drawButton;
JButton clipButton;
JButton clipboxButton;
JTextField x1field=new JTextField(3);
JTextField y1field=new JTextField(3);;
JTextField x2field=new JTextField(3);;
JTextField y2field=new JTextField(3);;
JLabel p1label=new JLabel("Punto 1: ");
JLabel p2label=new JLabel("Punto 2: ");
Color mycolor = new Color(146, 217, 216);
JMenu menu1=new JMenu("Retta");
JMenu menu2=new JMenu("Documento Storia");
JMenu menu3=new JMenu("?");
java.awt.List lista=new java.awt.List(30);
ClipPanel mypanel=new ClipPanel();
JLabel clipLabel=new JLabel("Rette del Clip-Box: x1= ");
JTextField x1retta=new JTextField(3);
JLabel clipx2=new JLabel("x2= ");
JLabel clipy1=new JLabel("y1= ");
JLabel clipy2=new JLabel("y2= ");
JTextField x2retta=new JTextField(3);
JTextField y1retta=new JTextField(3);
JTextField y2retta=new JTextField(3);
JLabel spaziolabel=new JLabel(" ");
private clipDati dialdati=new clipDati(this,"Dati del Clipping",true);
BorderLayout borderLayout1 = new BorderLayout();
JPanel jPanel1 = new JPanel();
BorderLayout borderLayout2 = new BorderLayout();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
GridLayout gridLayout1 = new GridLayout();
JPanel jPanel4 = new JPanel();
JPanel jPanel5 = new JPanel();
JPanel jPanel6 = new JPanel();
JButton GommaButton = new JButton();
JButton datiBtn = new JButton();
JButton newrettaBtn = new JButton();
public ClipFrame() {
super("Clipping di Cyrus-Beck");
setSize(600, 400);
setExtendedState(MAXIMIZED_BOTH);
try{
jbInit();
}
catch(Exception ex){
ex.printStackTrace();
}
}
public void jbInit() throws MalformedURLException {
jPanel1.setBackground(mycolor);
jPanel1.setLayout(borderLayout2);
GommaButton.setToolTipText("Cancella la tabella dei dati in alto");
datiBtn.setToolTipText("Visualizza i dati del clipping");
newrettaBtn.setToolTipText("Digitare per disegnare una nuova retta");
getContentPane().add(new JScrollPane(mypanel), "Center");
jPanel3.setBackground(mycolor);
jPanel3.setPreferredSize(new Dimension(10, 40));
jPanel2.setLayout(gridLayout1);
gridLayout1.setColumns(1);
gridLayout1.setRows(3);
jPanel2.setBackground(mycolor);
jPanel4.setBackground(mycolor);
jPanel5.setBackground(mycolor);
jPanel6.setBackground(mycolor);
jPanel6.setFont(new java.awt.Font("MS Sans Serif", 0, 11));
GommaButton.setPreferredSize(new Dimension(30, 24));
GommaButton.setHorizontalTextPosition(SwingConstants.CENTER);
GommaButton.setIcon(new ImageIcon(new java.net.URL("file:///C:/Documents and Settings/Gio cable/jbproject/Myframe/images/clear.PNG")));
GommaButton.setBorder(BorderFactory.createRaisedBevelBorder());
datiBtn.setPreferredSize(new Dimension(35, 34));
datiBtn.setHorizontalTextPosition(SwingConstants.CENTER);
datiBtn.setIcon(new ImageIcon(new java.net.URL("file:///C:/Documents and Settings/Gio cable/jbproject/Myframe/images/dati.PNG")));
datiBtn.setBorder(BorderFactory.createRaisedBevelBorder());
newrettaBtn.setPreferredSize(new Dimension(60, 30));
newrettaBtn.setIcon(new ImageIcon(new java.net.URL("file:///C:/Documents and Settings/Gio cable/jbproject/Myframe/images/newretta.PNG")));
newrettaBtn.setBorder(BorderFactory.createRaisedBevelBorder());
x1field.setHorizontalAlignment(SwingConstants.CENTER);
y1field.setHorizontalAlignment(SwingConstants.CENTER);
x2field.setHorizontalAlignment(SwingConstants.CENTER);
y2field.setHorizontalAlignment(SwingConstants.CENTER);
x1retta.setHorizontalAlignment(SwingConstants.CENTER);
x2retta.setHorizontalAlignment(SwingConstants.CENTER);
y1retta.setHorizontalAlignment(SwingConstants.CENTER);
y2retta.setHorizontalAlignment(SwingConstants.CENTER);
JPanel controls = new JPanel();
JPanel datiPanel = new JPanel();
datiPanel.setLayout(borderLayout1);
clipboxButton=new JButton("Clip-Box");
clipboxButton.setPreferredSize(new Dimension(60,25));
clipboxButton.setBackground(mycolor);
clipboxButton.setBorder(BorderFactory.createRaisedBevelBorder());
controls.setBorder(new EmptyBorder(5, 5, 5, 5));
drawButton = new JButton("Retta");
clipButton = new JButton("Clippa");
drawButton.setPreferredSize(new Dimension(60,25));
clipButton.setPreferredSize(new Dimension(60,25));
controls.add(p1label);
controls.add(x1field);
controls.add(y1field);
controls.add(p2label);
controls.add(x2field);
controls.add(y2field);
controls.setBackground(mycolor);
drawButton.setBorder(BorderFactory.createRaisedBevelBorder());
clipButton.setBorder(BorderFactory.createRaisedBevelBorder());
drawButton.setBackground(mycolor);
clipButton.setBackground(mycolor);
drawButton.addActionListener(this);
controls.add(spaziolabel);
controls.add(clipLabel);
controls.add(x1retta);
controls.add(clipx2);
controls.add(x2retta);
controls.add(clipy1);
controls.add(y1retta);
controls.add(clipy2);
controls.add(y2retta);
controls.add(drawButton);
controls.add(clipboxButton);
controls.add(clipButton);
controls.setPreferredSize(new Dimension(this.WIDTH,40));
datiPanel.setPreferredSize(new Dimension(150,40));
datiPanel.setBackground(mycolor);
clipButton.addActionListener(this);
clipboxButton.addActionListener(this);
getContentPane().add(controls, "South");
getContentPane().add(datiPanel,"East");
datiPanel.add(jPanel1, BorderLayout.CENTER);
//getContentPane().add(menu1);
//getContentPane().add(menu2);
//getContentPane().add(menu3);
setVisible(true);
jPanel1.add(jPanel2, BorderLayout.CENTER);
jPanel2.add(jPanel4, null);
jPanel4.add(GommaButton, null);
jPanel2.add(jPanel6, null);
jPanel6.add(datiBtn, null);
jPanel2.add(jPanel5, null);
jPanel5.add(newrettaBtn, null);
jPanel1.add(jPanel3, BorderLayout.SOUTH);
}
public void ArraySort(int[] vec){
int lung=0;
int i=0;
}
private Point[] CalcolaClip(int x1,int x2,int y1,int y2,Point p0,Point p1){
//variabili
int xmin,xmax,ymin,ymax;
Point D=new Point(p1.x-p0.x,p1.y-p0.y);
float[] TETL = new float[2];
Point[] rettaClippata=new Point[2];
float[] tpe=new float[2];
float[] tpl=new float[2];
if(x1<x2){
xmin = x1;
xmax = x2;
}
else{
xmin = x2;
xmax = x1;
}
if(y1<y2){
ymin = y1;
ymax = y2;
}
else{
ymin = y2;
ymax = y1;
}
//punti riguardanti le normali uscenti
Point[] ni = new Point[4];
ni[0] = new Point(-1,0);//xmin
ni[1] = new Point(1,0);//xmax
ni[2] = new Point(0,-1);//ymin
ni[3] = new Point(0,1);//ymax
//punti arbitrari sulla retta di clipping
Point[] pei = new Point[4];
pei[0] = new Point(xmin,0);
pei[1] = new Point(xmax,0);
pei[2] = new Point(0,ymin);
pei[3] = new Point(0,ymax);
/* visto che nella formula per il calcolo di t i valori
contenuti in questo vettore hanno il - davanti li calcolo
direttamente in quantità negative */
int[] NiD = new int[4];
for(int i=0;i<4;i++)
NiD[i] = -(ni[i].x*D.x+ni[i].y*D.y);
//Ni(p0-Pei)
int[] NiP0Pei=new int[4];
for(int i=0;i<4;i++)
NiP0Pei[i] = ni[i].x*(p0.x-pei[i].x)+ni[i].y*(p0.y-pei[i].y);
for(int i=0;i<4;i++)
System.out.println("nipopei("+i+1+")"+NiP0Pei[i]);
//vedere se la retta è PE o PL
String[] PEPL = new String[4];
for(int i=0;i<4;i++){
if (NiD[i] > 0)
PEPL[i] = "pe";
else
PEPL[i] = "pl";
}
float[] t = new float[4];
for(int i=0;i<4;i++){
if((float) NiP0Pei[i] / NiD[i]>=0 && (float) NiP0Pei[i] / NiD[i]<=1)
t[i] = (float) NiP0Pei[i] / NiD[i];
else{
JOptionPane.showMessageDialog(this,"Linea esterna al Clip-Box","Linea Esterna",JOptionPane.ERROR_MESSAGE);
/*if(NiD[i]<0)
t[i]=-1000;
else
t[i]=1000;*/
rettaClippata[0]=new Point(-500,-500);
rettaClippata[1]=new Point(-500,-500);
return rettaClippata;
}
}
for(int i=0;i<4;i++)
System.out.println("t("+i+1+")"+t[i]);
int j=0;
int k=0;
for(int i=0;i<4;i++){
if(PEPL[i]=="pe")
tpe[j++] = t[i];
else
if(PEPL[i]=="pl")
tpl[k++] = t[i];
}
if(tpe[0]>tpe[1])
TETL[1]=tpe[0];
else
TETL[1]=tpe[1];
if(tpl[0]<tpl[1])
TETL[0]=tpl[0];
else
TETL[0]=tpl[1];
System.out.println("rettaclippata:t1 : "+TETL[0]+" t2: "+TETL[1]);
int prova1x=Math.round(p0.x+D.x*TETL[0]*30);
int prova1y=Math.round(p0.y+D.y*TETL[0]*30);
int prova2x=Math.round(p1.x+D.x*TETL[1]*30);
int prova2y=Math.round(p1.y+D.y*TETL[1]*30);
Point pa=new Point(Math.round(p0.x+D.x*TETL[0]),Math.round(p0.y+D.y*TETL[0]));
Point pb=new Point(Math.round(p0.x+D.x*TETL[1]),Math.round(p0.y+D.y*TETL[1]));
rettaClippata[0]=pa;
rettaClippata[1]=pb;
dialdati.compilaClipDati(x1,x2,y1,y2,pei,NiD,NiP0Pei,PEPL,t);
dialdati.insDati();
//System.out.println("dialdati,compilaclipdati\nt:"+t.toString());
return rettaClippata;
}
private void copia(Vector v1, Vector v2){
v2.clear();
for(int i=0;i < v1.size() ; i++){
v2.add(v1.get(i));
}
}
public void actionPerformed(ActionEvent e){
Object source = e.getSource();
if(source == drawButton){
try{
int x1 = Integer.parseInt(x1field.getText());
int y1 = Integer.parseInt(y1field.getText());
int x2 = Integer.parseInt(x2field.getText());
int y2 = Integer.parseInt(y2field.getText());
if((x1 < 0) || (x1 > hSize/size) || (y1 < 0) || (y1 >=vSize/size)){
JOptionPane.showMessageDialog(this,
"Il punto p1 non appartiene allo screen", "Errore",
JOptionPane.ERROR_MESSAGE);
x1field.setText("");
y1field.setText("");
x2field.setText("");
y2field.setText("");
}
else if((x2 < 0) || (x2 > hSize/size) || (y2 < 0) || (y2 >= vSize/size)){
JOptionPane.showMessageDialog(this,
"Il punto p2 non appartiene allo screen", "Errore",
JOptionPane.ERROR_MESSAGE);
x1field.setText("");
y1field.setText("");
x2field.setText("");
y2field.setText("");
}
else
mypanel.setRetta(x1,y1,x2,y2);
}
catch(NumberFormatException nfe){
JOptionPane.showMessageDialog(this, "Una delle coordinate inserite non rappresenta un numero intero", "Errore", JOptionPane.ERROR_MESSAGE);
x1field.setText("");
y1field.setText("");
x2field.setText("");
y2field.setText("");
}
}
if(source == clipButton){
try{
int x1 = Integer.parseInt(x1field.getText());
int y1 = Integer.parseInt(y1field.getText());
int x2 = Integer.parseInt(x2field.getText());
int y2 = Integer.parseInt(y2field.getText());
int xa = Integer.parseInt(x1retta.getText());
int ya = Integer.parseInt(y1retta.getText());
int xb = Integer.parseInt(x2retta.getText());
int yb = Integer.parseInt(y2retta.getText());
System.out.println("clipframe,x1y1x2y2: "+x1+y1+x2+y2+"\n"+xa+ya+xb+yb);
Point[] newRetta = CalcolaClip(xa,xb,ya,yb,new Point(x1,y1),new Point(x2,y2));
Point p0 = newRetta[0];
Point p1 = newRetta[1];
mypanel.setRetta(p0.x,p0.y,p1.x,p1.y);
mypanel.repaint();
}
catch(NumberFormatException ex){
JOptionPane.showMessageDialog(this,
"Le coordinate inserite non rappresentano valori reali",
"Errore di inserimento",JOptionPane.ERROR_MESSAGE);
}
return;
}
if(source == GommaButton){
lista.removeAll();
}
if(source == datiBtn){
dialdati.setVisible(true);
}
if(source == clipboxButton){
try {
int xa = Integer.parseInt(x1retta.getText());
int ya = Integer.parseInt(y1retta.getText());
int xb = Integer.parseInt(x2retta.getText());
int yb = Integer.parseInt(y2retta.getText());
if ( (xa < 0) || (xa > hSize/size) || (ya < 0) || (ya >= vSize/size)) {
JOptionPane.showMessageDialog(this,
"Il punto p1 non appartiene allo screen",
"Errore",
JOptionPane.ERROR_MESSAGE);
x1retta.setText("");
y1retta.setText("");
x2retta.setText("");
y2retta.setText("");
}
if ( (xb < 0) || (xb > hSize / size) || (yb < 0) || (yb >= vSize / size)) {
JOptionPane.showMessageDialog(this,
"Il punto p2 non appartiene allo screen",
"Errore",
JOptionPane.ERROR_MESSAGE);
x1retta.setText("");
y1retta.setText("");
x2retta.setText("");
y2retta.setText("");
}
mypanel.setClipBox(xa, xb, ya, yb);
}
catch(NumberFormatException ex){
ex.printStackTrace();
}
}
return;
}
}
Non spaventarti ti allego anche i file,purtroppo non c'è il main in nessuno di questi file sennò dovevo postare tutto il progetto e non era il caso,basta che ti crei un JFrame richiama il poloyLabDialog che ho creato e sta a posto
vBulletin® v3.6.4, Copyright ©2000-2025, Jelsoft Enterprises Ltd.