Example #1
0
 void update() {
   ThingWithProperties show = graph.getSelection();
   if (show != null) {
     Vector props = show.getProperties();
     // new
     lab[0].setText(((Property) props.elementAt(0)).toString());
     lab[1].setText(((Property) props.elementAt(1)).toString());
     if (dl1 != null) textfields[0].getDocument().removeDocumentListener(dl1);
     if (dl2 != null) textfields[1].getDocument().removeDocumentListener(dl2);
     dl1 = new PropertyListener((Property) props.elementAt(0));
     dl2 = new PropertyListener((Property) props.elementAt(1));
     textfields[0].getDocument().addDocumentListener(dl1);
     textfields[1].getDocument().addDocumentListener(dl2);
     textfields[0].setText(((Property) props.elementAt(0)).get());
     textfields[0].setEditable(((Property) props.elementAt(0)).getEditable());
     textfields[1].setText(((Property) props.elementAt(1)).get());
     textfields[1].setEditable(((Property) props.elementAt(1)).getEditable());
     /*	    setLayout(new GridLayout(2, props.size()));
        JTextField tf;
        Property p;
        JLabel n;
        for (int i = 0; i < props.size(); i++) {
     p = (Property) props.elementAt(i);
     System.out.println("Proprty " + p);
     n = new JLabel(p.toString());
     tf = new JTextField(3);
     add(n);
     add(tf);
     tf.setText(p.get());
     tf.setEditable(p.getEditable());
     tf.getDocument().addDocumentListener(new PropertyListener(p));
     }*/
   }
   repaint();
 }
Example #2
0
 public void paintComponent(Graphics g) {
   if (position == null) return;
   int x = (int) position.getX();
   int y = (int) position.getY();
   if (parent.inFirstPath(this)) {
     g.setColor(Color.yellow);
     g.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   } else if (parent.inQueue(this)) {
     g.setColor(Color.orange);
     g.fillOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   }
   g.setColor(getColor());
   g.drawOval(x - RADIUS, y - RADIUS, 2 * RADIUS, 2 * RADIUS);
   if (parent.isGoalNode(this)) g.setColor(Color.green);
   else if (parent.isStartNode(this)) g.setColor(Color.blue);
   g.drawString(toString(), x, y);
   if (!parent.getHideHeur()) g.drawString(model.getHeuristic() + "", x + RADIUS, y + RADIUS);
 }
Example #3
0
 // TEMPORARY SOLUTION!
 public void repaint() {
   parent.repaint();
 }