예제 #1
0
 // the MouseListener events
 public void mousePressed(MouseEvent evt) {
   Dimension dim = getSize();
   String layerName = (String) dialog.threeDLayerList.getSelectedValue();
   Layer selectedLayer = dialog.curTech.findLayer(layerName);
   GenMath.MutableDouble height = dialog.threeDDistanceMap.get(selectedLayer);
   int yValue =
       dim.height
           - (int)
               ((height.doubleValue() - lowHeight) / (highHeight - lowHeight) * dim.height
                   + 0.5);
   if (Math.abs(yValue - evt.getY()) > 5) {
     int bestDist = dim.height;
     for (Iterator<Layer> it = dialog.curTech.getLayers(); it.hasNext(); ) {
       Layer layer = it.next();
       if (layer.isPseudoLayer()) continue;
       height = dialog.threeDDistanceMap.get(layer);
       yValue =
           dim.height
               - (int)
                   ((height.doubleValue() - lowHeight) / (highHeight - lowHeight) * dim.height
                       + 0.5);
       int dist = Math.abs(yValue - evt.getY());
       if (dist < bestDist) {
         bestDist = dist;
         selectedLayer = layer;
       }
     }
     dialog.threeDLayerList.setSelectedValue(selectedLayer.getName(), true);
     dialog.threeDValuesChanged(false);
   }
 }
예제 #2
0
 /** Method called when the "OK" panel is hit. Updates any changed fields in the 3D tab. */
 @Override
 public void term() {
   for (Iterator<Layer> it = curTech.getLayers(); it.hasNext(); ) {
     Layer layer = it.next();
     assert !layer.isPseudoLayer();
     GenMath.MutableDouble thickness = threeDThicknessMap.get(layer);
     GenMath.MutableDouble height = threeDDistanceMap.get(layer);
     setDouble(layer.getThicknessSetting(), thickness.doubleValue());
     setDouble(layer.getDistanceSetting(), height.doubleValue());
   }
 }
예제 #3
0
 public void mouseDragged(MouseEvent evt) {
   Dimension dim = getSize();
   String layerName = (String) dialog.threeDLayerList.getSelectedValue();
   Layer layer = dialog.curTech.findLayer(layerName);
   GenMath.MutableDouble height = threeDDistanceMap.get(layer);
   double newHeight =
       (double) (dim.height - evt.getY()) / dim.height * (highHeight - lowHeight) + lowHeight;
   if (height.doubleValue() != newHeight) {
     height.setValue(newHeight);
     dialog.threeDHeight.setText(TextUtils.formatDistance(newHeight));
     repaint();
   }
 }
예제 #4
0
    /** Method to repaint this ThreeDSideView. */
    @Override
    public void paint(Graphics g) {
      Dimension dim = getSize();
      g.setColor(Color.WHITE);
      g.fillRect(0, 0, dim.width, dim.height);
      g.setColor(Color.BLACK);
      g.drawLine(0, 0, 0, dim.height - 1);
      g.drawLine(0, dim.height - 1, dim.width - 1, dim.height - 1);
      g.drawLine(dim.width - 1, dim.height - 1, dim.width - 1, 0);
      g.drawLine(dim.width - 1, 0, 0, 0);

      String layerName = (String) dialog.threeDLayerList.getSelectedValue();
      Layer selectedLayer = dialog.curTech.findLayer(layerName);
      for (Iterator<Layer> it = dialog.curTech.getLayers(); it.hasNext(); ) {
        Layer layer = it.next();
        if (layer.isPseudoLayer()) continue;
        // if (!layer.isVisible()) continue;
        if (layer == selectedLayer) g.setColor(Color.RED);
        else g.setColor(Color.BLACK);
        GenMath.MutableDouble thickness = dialog.threeDThicknessMap.get(layer);
        GenMath.MutableDouble distance = dialog.threeDDistanceMap.get(layer);
        double dis = distance.doubleValue() + thickness.doubleValue() / 2;
        int yValue =
            dim.height - (int) ((dis - lowHeight) / (highHeight - lowHeight) * dim.height + 0.5);
        int yHeight = (int) (thickness.doubleValue() / (highHeight - lowHeight) * dim.height + 0.5);
        if (yHeight == 0) {
          g.drawLine(0, yValue, dim.width / 3, yValue);
        } else {
          // yHeight -= 4;
          int firstPart = dim.width / 6;
          int pointPos = dim.width / 4;
          g.drawLine(0, yValue - yHeight / 2, firstPart, yValue - yHeight / 2);
          g.drawLine(0, yValue + yHeight / 2, firstPart, yValue + yHeight / 2);
          g.drawLine(firstPart, yValue - yHeight / 2, pointPos, yValue);
          g.drawLine(firstPart, yValue + yHeight / 2, pointPos, yValue);
          g.drawLine(pointPos, yValue, dim.width / 3, yValue);
        }
        String string = layer.getName();
        Font font = new Font(User.getDefaultFont(), Font.PLAIN, 9);
        g.setFont(font);
        FontRenderContext frc = new FontRenderContext(null, true, true);
        GlyphVector gv = font.createGlyphVector(frc, string);
        LineMetrics lm = font.getLineMetrics(string, frc);
        double txtHeight = lm.getHeight();
        Graphics2D g2 = (Graphics2D) g;
        g2.drawGlyphVector(
            gv, dim.width / 3 + 1, (float) (yValue + txtHeight / 2) - lm.getDescent());
      }
    }
예제 #5
0
    ThreeDSideView(ThreeDTab dialog) {
      this.dialog = dialog;
      addMouseListener(this);
      addMouseMotionListener(this);

      LayerVisibility lv = LayerVisibility.getLayerVisibility();
      for (Iterator<Layer> it = dialog.curTech.getLayers(); it.hasNext(); ) {
        Layer layer = it.next();
        if (layer.isPseudoLayer()) continue;
        if (!lv.isVisible(layer)) continue;
        GenMath.MutableDouble thickness = dialog.threeDThicknessMap.get(layer);
        GenMath.MutableDouble distance = dialog.threeDDistanceMap.get(layer);
        double dis = distance.doubleValue();
        double thick = thickness.doubleValue() / 2;
        double valLow = dis - thick;
        double valHig = dis + thick;

        if (valLow < lowHeight) lowHeight = valLow;
        if (valHig > highHeight) highHeight = valHig;
      }
      lowHeight -= 4;
      highHeight += 4;
    }
예제 #6
0
 private void threeDValuesChanged(boolean set) {
   if (!set) initial3DTextChanging = true;
   else if (initial3DTextChanging) return;
   String layerName = (String) threeDLayerList.getSelectedValue();
   Layer layer = curTech.findLayer(layerName);
   if (layer == null) return;
   GenMath.MutableDouble thickness = threeDThicknessMap.get(layer);
   GenMath.MutableDouble height = threeDDistanceMap.get(layer);
   if (set) {
     thickness.setValue(TextUtils.atofDistance(threeDThickness.getText()));
     height.setValue(TextUtils.atofDistance(threeDHeight.getText()));
   } else {
     threeDHeight.setText(TextUtils.formatDistance(height.doubleValue()));
     threeDThickness.setText(TextUtils.formatDistance(thickness.doubleValue()));
   }
   if (!set) initial3DTextChanging = false;
   threeDSideView.repaint();
 }