Пример #1
0
 /**
  * Sets the model and notofies children to reflect the changes.
  *
  * @param model The model to set.
  */
 public void setModel(DriveTrain model) {
   this.model = model;
   generalTranslationInput.setModel(model);
   generalGeometryInput.setModel(model);
   chainwheelTranslationInput.setModel(model.getChainwheels());
   chainwheelGeometryInput.setModel(model.getChainwheels());
   sprocketTranslationInput.setModel(model.getSprockets());
   sprocketGeometryInput.setModel(model.getSprockets());
   driveTrainDrawing.setModel(model);
   driveTrainOutput.setModel(model);
   update();
   driveTrainOutput.structureChanged();
 }
Пример #2
0
  /**
   * Creates the geomerty input tabbed page
   *
   * @param tabbedPane The TabbedPane to add the tab to
   */
  private void getGeometryInput(JTabbedPane tabbedPane) {
    JPanel geometryInput = new JPanel(new GridBagLayout());

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridwidth = REMAINDER;
    gbc.fill = BOTH;
    gbc.anchor = NORTHWEST;
    gbc.weighty = 1.0;

    chainwheelGeometryInput.addContentChangeListener(this);
    geometryInput.add(chainwheelGeometryInput, gbc);

    sprocketGeometryInput.addContentChangeListener(this);
    geometryInput.add(sprocketGeometryInput, gbc);

    generalGeometryInput.addContentChangeListener(this);
    geometryInput.add(generalGeometryInput, gbc);

    driveTrainDrawing.addContentChangeListener(this);
    driveTrainOutput.addContentChangeListener(this);

    tabbedPane.addTab(
        Messages.getString("GeometryDetails"),
        null,
        geometryInput,
        Messages.getString("GeometryDetailsTip"));
  }
Пример #3
0
 /** Support method to notify children of any changes to model or style. */
 public void update() {
   generalTranslationInput.update();
   generalGeometryInput.update();
   driveTrainDrawing.update();
   driveTrainOutput.update();
   chainwheelTranslationInput.update();
   chainwheelGeometryInput.update();
   sprocketTranslationInput.update();
   sprocketGeometryInput.update();
 }
Пример #4
0
 /**
  * Implements the "Printable" interface, does the actual printing layout and draws the component
  * to the printer's graphics context.
  */
 public int print(Graphics graphics, PageFormat pageFormat, int pageIndex)
     throws PrinterException {
   if (pageIndex == 0) {
     Graphics2D g = (Graphics2D) graphics;
     g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
     g.setRenderingHint(
         RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
     AffineTransform origTransform = g.getTransform();
     g.translate(pageFormat.getImageableX(), pageFormat.getImageableY() + 40);
     g.setFont(new Font("Verdana", Font.BOLD, 20));
     g.drawString(model.getFile().getName(), 0, -20);
     g.setFont(new Font("Verdana", Font.PLAIN, 11));
     g.drawString(
         " " + Messages.getString("Cadence") + ": " + model.getCadence().getStringValue(), 0, -3);
     driveTrainOutput.print(g, pageFormat);
     driveTrainDrawing.print(g, pageFormat);
     g.setTransform(origTransform);
     return Printable.PAGE_EXISTS;
   } else {
     return Printable.NO_SUCH_PAGE;
   }
 }
Пример #5
0
 /**
  * Sets the unit system for this instance and ensures that children reflect the change.
  *
  * @param unitSystem The new unit system
  */
 public void setUnitSystem(UnitSystem unitSystem) {
   model.setUnitSystem(unitSystem);
   update();
   driveTrainOutput.structureChanged();
 }
Пример #6
0
 /**
  * Implements ContentChangeListener.contentChanged(). Flags the model as modified and updates all
  * child components to reflect the new model values. Then itself fires a contentChangeEvent to
  * notify listeners of the change.
  */
 public void contentChanged(ChangeEvent e) {
   model.setModified(true);
   update();
   driveTrainOutput.dataChanged();
   fireContentChanged();
 }