Ejemplo n.º 1
0
 protected void trainIconMoved(java.awt.event.ComponentEvent ae) {
   if (ae.getSource() == _tIon) {
     log.debug("train icon X: {} Y: {}", _tIon.getLocation().x, _tIon.getLocation().y);
     spinTrainIconX.setValue(_tIon.getLocation().x);
     spinTrainIconY.setValue(_tIon.getLocation().y);
   }
 }
Ejemplo n.º 2
0
 public void spinnerChangeEvent(javax.swing.event.ChangeEvent ae) {
   if (ae.getSource() == spinTrainIconX && _tIon != null) {
     _tIon.setLocation((Integer) spinTrainIconX.getValue(), _tIon.getLocation().y);
   }
   if (ae.getSource() == spinTrainIconY && _tIon != null) {
     _tIon.setLocation(_tIon.getLocation().x, (Integer) spinTrainIconY.getValue());
   }
 }
Ejemplo n.º 3
0
 private void setTrainIconNameAndColor() {
   if (_tIon == null) {
     return;
   }
   _tIon.setText(_rl.getName());
   // set color based on train direction at current location
   if (_rl.getTrainDirection() == RouteLocation.NORTH) {
     _tIon.setLocoColor(Setup.getTrainIconColorNorth());
   }
   if (_rl.getTrainDirection() == RouteLocation.SOUTH) {
     _tIon.setLocoColor(Setup.getTrainIconColorSouth());
   }
   if (_rl.getTrainDirection() == RouteLocation.EAST) {
     _tIon.setLocoColor(Setup.getTrainIconColorEast());
   }
   if (_rl.getTrainDirection() == RouteLocation.WEST) {
     _tIon.setLocoColor(Setup.getTrainIconColorWest());
   }
 }
Ejemplo n.º 4
0
 // place test markers on panel
 private void placeTestIcons() {
   Editor editor = PanelMenu.instance().getEditorByName(Setup.getPanelName());
   if (editor == null) {
     JOptionPane.showMessageDialog(
         this,
         MessageFormat.format(Bundle.getMessage("LoadPanel"), new Object[] {Setup.getPanelName()}),
         Bundle.getMessage("PanelNotFound"),
         JOptionPane.ERROR_MESSAGE);
   } else {
     if (_tIon != null) {
       _tIon.remove();
     }
     // icon
     _tIon = editor.addTrainIcon(_rl.getName());
     _tIon.getTooltip().setText(_route.getName());
     _tIon.getTooltip().setBackgroundColor(Color.white);
     _tIon.setLocation(_rl.getTrainIconX(), _rl.getTrainIconY());
     setTrainIconNameAndColor();
     addIconListener(_tIon);
   }
 }
Ejemplo n.º 5
0
  private void addIconListener(TrainIcon tI) {
    tI.addComponentListener(
        new ComponentListener() {
          public void componentHidden(java.awt.event.ComponentEvent e) {}

          public void componentShown(java.awt.event.ComponentEvent e) {}

          public void componentMoved(java.awt.event.ComponentEvent e) {
            trainIconMoved(e);
          }

          public void componentResized(java.awt.event.ComponentEvent e) {}
        });
  }
Ejemplo n.º 6
0
 private void removeIcons() {
   if (_tIon != null) {
     _tIon.remove();
   }
 }