Package org.openpnp.model

Examples of org.openpnp.model.Length


          double xPos = l.getX();
          double yPos = l.getY();
          double zPos = l.getZ();
          double cPos = l.getRotation();

          double jogIncrement = new Length(machineControlsPanel
              .getJogIncrement(), configuration.getSystemUnits())
              .getValue();

          if (x > 0) {
            xPos += jogIncrement;
View Full Code Here


  public LengthCellValue(Length length) {
    this(length, false);
  }

  public LengthCellValue(String value) {
    Length length = Length.parse(value, false);
    if (length == null) {
      throw new NullPointerException();
    }
    setLength(length);
  }
View Full Code Here

    this.displayNativeUnits = displayNativeUnits;
  }

  @Override
  public String toString() {
    Length l = length;
    if (l.getUnits() == null) {
      return String.format(configuration.getLengthDisplayFormatWithUnits(), l.getValue(), "?");
    }
    if (displayNativeUnits && l.getUnits() != configuration.getSystemUnits()) {
      return String.format(configuration.getLengthDisplayFormatWithUnits(), l.getValue(), l.getUnits().getShortName());
    }
    else {
      l = l.convertToUnits(configuration.getSystemUnits());
      return String.format(configuration.getLengthDisplayFormat(), l.getValue());
    }
  }
View Full Code Here

    decorateWithAutoSelect(textField);
    decorateWithLengthConversion(textField);
  }

  private static void convertLength(JTextField textField) {
    Length length = Length.parse(textField.getText(), false);
    if (length == null) {
      return;
    }
    if (length.getUnits() == null) {
      length.setUnits(Configuration.get().getSystemUnits());
    }
    length = length.convertToUnits(Configuration.get().getSystemUnits());
    textField.setText(String.format(Configuration.get().getLengthDisplayFormat(), length.getValue()));
  }
View Full Code Here

    if (shape == null) {
        return;
    }
    // Determine the scaling factor to go from Outline units to
    // Camera units.
    Length l = new Length(1, footprint.getUnits());
    l = l.convertToUnits(cameraUnitsPerPixelUnits);
    double unitScale = l.getValue();
   
    // Create a transform to scale the Shape by
    AffineTransform tx = new AffineTransform();
   
        tx.translate(viewPortCenterX, viewPortCenterY);
View Full Code Here

        g2d.translate(viewPortCenterX, viewPortCenterY);
        // AffineTransform rotates positive clockwise, so we invert the value.
        g2d.rotate(Math.toRadians(-rotation));

        double uppX = new Length(cameraUnitsPerPixelX, cameraUnitsPerPixelUnits)
                .convertToUnits(this.units).getValue();
        double uppY = new Length(cameraUnitsPerPixelY, cameraUnitsPerPixelUnits)
                .convertToUnits(this.units).getValue();
        double pixelsPerTickX = unitsPerTick / uppX;
        double pixelsPerTickY = unitsPerTick / uppY;
        int tickLength = 10;
View Full Code Here

        g2d.translate(viewPortCenterX, viewPortCenterY);
        // AffineTransform rotates positive clockwise, so we invert the value.
        g2d.rotate(Math.toRadians(-rotation));

        double pixelsPerUnitX = 1.0 / new Length(cameraUnitsPerPixelX,
                cameraUnitsPerPixelUnits).convertToUnits(this.units).getValue();
        double pixelsPerUnitY = 1.0 / new Length(cameraUnitsPerPixelY,
                cameraUnitsPerPixelUnits).convertToUnits(this.units).getValue();

        int width = (int) (size * pixelsPerUnitX);
        int height = (int) (size * pixelsPerUnitY);
        int x = (int) -(width / 2);
View Full Code Here

    if (shape == null) {
        return;
    }
    // Determine the scaling factor to go from Outline units to
    // Camera units.
    Length l = new Length(1, outline.getUnits());
    l = l.convertToUnits(cameraUnitsPerPixelUnits);
    double unitScale = l.getValue();
   
    // Create a transform to scale the Shape by
    AffineTransform tx = new AffineTransform();
   
        tx.translate(viewPortCenterX, viewPortCenterY);
View Full Code Here

    return String.format(Configuration.get().getLengthDisplayFormat(), length.getValue());
  }
 
  @Override
  public Length convertReverse(String s) {
    Length length = Length.parse(s, false);
    if (length == null) {
      throw new RuntimeException("Unable to parse " + s);
    }
    if (length.getUnits() == null) {
      length.setUnits(Configuration.get().getSystemUnits());
    }
    return length;
  }
View Full Code Here

        part.setName((String) aValue);
      }
      else if (columnIndex == 2) {
        LengthCellValue value = (LengthCellValue) aValue;
        value.setDisplayNativeUnits(true);
        Length length = value.getLength();
        Length oldLength = part.getHeight();
        if (length.getUnits() == null) {
          if (oldLength != null) {
            length.setUnits(oldLength.getUnits());
          }
          if (length.getUnits() == null) {
            length.setUnits(configuration.getSystemUnits());
          }
        }
View Full Code Here

TOP

Related Classes of org.openpnp.model.Length

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.