private void recalculateMaxValues() {
      myIdxLeft = widestEditor(myLeftEditors);
      final Editor leftEditor = myLeftEditors.get(myIdxLeft);
      final int wholeWidth = leftEditor.getContentComponent().getWidth();
      final Rectangle va = leftEditor.getScrollingModel().getVisibleArea();
      final int visibleLeft = leftEditor.xyToVisualPosition(new Point(va.width, 0)).column;

      myMaxColumnsLeft = (int) (visibleLeft * ((double) wholeWidth / va.getWidth()));

      myIdxRight = widestEditor(myRightEditors);
      final Editor rightEditor = myRightEditors.get(myIdxRight);
      final int wholeWidthRight = rightEditor.getContentComponent().getWidth();
      final Rectangle vaRight = rightEditor.getScrollingModel().getVisibleArea();
      final int visibleRight = rightEditor.xyToVisualPosition(new Point(va.width, 0)).column;

      myMaxColumnsRight = (int) (visibleRight * ((double) wholeWidthRight / vaRight.getWidth()));

      myByLeft = !(myMaxColumnsLeft <= visibleLeft);
      if (!myByLeft) {
        // check right editor
        if (myLeftScroll.getVisibleAmount() != visibleRight) {
          myLeftScroll.setVisibleAmount(visibleRight);
        }
        myLeftScroll.setMaximum(myMaxColumnsRight);
      } else {
        if (myLeftScroll.getVisibleAmount() != visibleLeft) {
          myLeftScroll.setVisibleAmount(visibleLeft);
        }
        myLeftScroll.setMaximum(myMaxColumnsLeft);
      }
    }
Exemplo n.º 2
0
  public void setVisible(boolean flag) {
    Rectangle rc = m_mainframe.getBounds();
    Rectangle rcthis = getBounds();
    setBounds(
        (int) (rc.getWidth() - rcthis.getWidth()) / 2 + rc.x,
        (int) (rc.getHeight() - rcthis.getHeight()) / 2 + rc.y,
        (int) rcthis.getWidth(),
        (int) rcthis.getHeight());

    super.setVisible(flag);
  }
Exemplo n.º 3
0
 // ------------------------------
 public void
     scrollToCaret() { // not called - fixed with putting visible scrollbars on JScrollPane
   //
   Rectangle rect1 = scroller1.getViewport().getViewRect();
   double x1 = rect1.getX();
   double y1 = rect1.getY();
   double r1height = rect1.getHeight();
   double r1width = rect1.getWidth();
   Caret caret1 = editor1.getCaret();
   Point pt2 = caret1.getMagicCaretPosition(); // the end of the string
   double x2 = pt2.getX();
   double y2 = pt2.getY();
   if (((x2 > x1) && (x2 < (x1 + r1width))) && ((y2 > y1) && (y2 < (y1 + r1height)))) {
     // inview
   } else {
     double newheight = r1height / 2;
     double newwidth = r1width / 2;
     double x3 = pt2.getX() - newwidth;
     double y3 = pt2.getY() - newheight;
     if (x3 < 0) x3 = 0;
     if (y3 < 0) y3 = 0;
     Rectangle rect3 = new Rectangle((int) x3, (int) y3, (int) newwidth, (int) newheight);
     editor1.scrollRectToVisible(rect3);
   }
 } // end scrollToCaret
Exemplo n.º 4
0
 private void setGraphicsCenter(Graphics2D graphics2D, SpriteLocation center) {
   Rectangle screen = graphics2D.getClipBounds();
   SpriteLocation screenCenter =
       new SpriteLocation(
           screen.getX() + screen.getWidth() * 0.5, screen.getY() + screen.getHeight() * 0.5);
   center = screenCenter.sub(center);
   graphics2D.translate(center.getX(), center.getY());
 }
 private static Rectangle fitToScreen(
     @NotNull Dimension newDim, @NotNull RelativePoint popupPosition, JTable table) {
   Rectangle rectangle = new Rectangle(popupPosition.getScreenPoint(), newDim);
   ScreenUtil.fitToScreen(rectangle);
   if (rectangle.getHeight() != newDim.getHeight()) {
     int newHeight = (int) rectangle.getHeight();
     int roundedHeight = newHeight - newHeight % table.getRowHeight();
     rectangle.setSize((int) rectangle.getWidth(), Math.max(roundedHeight, table.getRowHeight()));
   }
   return rectangle;
 }
Exemplo n.º 6
0
  public void dupliquer() {
    for (Shape s : shapeSelect) {
      Point p = new Point(s.getOrigin());
      p.y += 100;

      if (s instanceof Rectangle) {
        Rectangle r = (Rectangle) s;
        shapes.add(new Rectangle(p, r.getWidth(), r.getHeight(), r.getColor()));
        cpt++;
        notifyObservers();
      }

      if (s instanceof Circle) {
        Circle c = (Circle) s;
        shapes.add(new Circle(p, c.getRadius(), c.getColor()));
        cpt++;
        notifyObservers();
      }
    }

    shapeSelect.clear();
    this.repaint();
  }
  /**
   * Method to check that the current position is in the viewing area and if not scroll to center
   * the current position if possible
   */
  public void checkScroll() {
    // get the x and y position in pixels
    int xPos = (int) (colIndex * zoomFactor);
    int yPos = (int) (rowIndex * zoomFactor);

    // only do this if the image is larger than normal
    if (zoomFactor > 1) {

      // get the rectangle that defines the current view
      JViewport viewport = scrollPane.getViewport();
      Rectangle rect = viewport.getViewRect();
      int rectMinX = (int) rect.getX();
      int rectWidth = (int) rect.getWidth();
      int rectMaxX = rectMinX + rectWidth - 1;
      int rectMinY = (int) rect.getY();
      int rectHeight = (int) rect.getHeight();
      int rectMaxY = rectMinY + rectHeight - 1;

      // get the maximum possible x and y index
      int macolIndexX = (int) (picture.getWidth() * zoomFactor) - rectWidth - 1;
      int macolIndexY = (int) (picture.getHeight() * zoomFactor) - rectHeight - 1;

      // calculate how to position the current position in the middle of the viewing
      // area
      int viewX = xPos - (int) (rectWidth / 2);
      int viewY = yPos - (int) (rectHeight / 2);

      // reposition the viewX and viewY if outside allowed values
      if (viewX < 0) viewX = 0;
      else if (viewX > macolIndexX) viewX = macolIndexX;
      if (viewY < 0) viewY = 0;
      else if (viewY > macolIndexY) viewY = macolIndexY;

      // move the viewport upper left point
      viewport.scrollRectToVisible(new Rectangle(viewX, viewY, rectWidth, rectHeight));
    }
  }
Exemplo n.º 8
0
 @NotNull
 private static List<EditorWindow> findWindowsInRow(
     @NotNull EditorWindow anchor, @NotNull List<EditorWindow> windows, final boolean vertical) {
   final Rectangle anchorRect = getEditorWindowRectangle(anchor);
   if (anchorRect != null) {
     final List<EditorWindow> result = new ArrayList<EditorWindow>();
     final double coord = vertical ? anchorRect.getX() : anchorRect.getY();
     for (EditorWindow window : windows) {
       final Rectangle rect = getEditorWindowRectangle(window);
       if (rect != null) {
         final double min = vertical ? rect.getX() : rect.getY();
         final double max = min + (vertical ? rect.getWidth() : rect.getHeight());
         if (coord >= min && coord <= max) {
           result.add(window);
         }
       }
     }
     Collections.sort(
         result,
         new Comparator<EditorWindow>() {
           @Override
           public int compare(EditorWindow window1, EditorWindow window2) {
             final Rectangle rect1 = getEditorWindowRectangle(window1);
             final Rectangle rect2 = getEditorWindowRectangle(window2);
             if (rect1 != null && rect2 != null) {
               final double diff =
                   vertical ? (rect1.getY() - rect2.getY()) : (rect1.getX() - rect2.getX());
               return diff < 0 ? -1 : diff > 0 ? 1 : 0;
             }
             return 0;
           }
         });
     return result;
   }
   return Collections.singletonList(anchor);
 }
Exemplo n.º 9
0
  public void showDialog(boolean showReplace) {
    getReplaceLabel().setVisible(showReplace);
    getReplaceTextField().setVisible(showReplace);
    getReplaceButton().setVisible(showReplace);
    getReplaceAllButton().setVisible(showReplace);
    if (showReplace) {
      setTitle("Replace");
      getRootPane().setDefaultButton(getReplaceButton());
      getReplaceFindButton().setText("Find...");
      getReplaceFindButton().setMnemonic('d');
      getReplaceFindButton().setDisplayedMnemonicIndex(3);
    } else {
      setTitle("Find");
      getRootPane().setDefaultButton(getFindNextButton());
      getReplaceFindButton().setText("Replace...");
      getReplaceFindButton().setMnemonic('R');
      getReplaceFindButton().setDisplayedMnemonicIndex(0);
    }

    pack();

    if (!initLoc && editor != null) {
      Rectangle bounds = editor.getBounds();
      Dimension size = getSize();

      setLocation(
          (int) (bounds.getX() + (bounds.getWidth() - size.getWidth()) / 2),
          (int) (bounds.getY() + (bounds.getHeight() - size.getHeight()) / 2));
      initLoc = true;
    }

    // Bugfix [2664844] - Editor: Find (set cursor position)
    getFindTextField().requestFocus();

    setVisible(true);
  }
      DOTItemDialog() {
        super();
        _primitiveForm = primitiveForm;
        _property = property;

        _dynamicDefinitionComponent =
            new DynamicDefinitionComponent(_configuration, new DOTPointPlugin());
        final Object propertyValue = initDynamicDefinitionComponent();

        final JPanel panel = new JPanel();
        panel.setLayout(new SpringLayout());

        JLabel aLabel = null;
        if (_property == DOTProperty.DURCHMESSER) {
          aLabel = new JLabel("Durchmesser: ");
          if (propertyValue != null) {
            _diameterSpinner.setValue(propertyValue);
          }
          _component = _diameterSpinner;
        } else if (_property == DOTProperty.FARBE || _property == DOTProperty.FUELLUNG) {
          aLabel = new JLabel("Farbe: ");
          if (propertyValue != null) {
            _colorComboBox.setSelectedItem(propertyValue);
          }
          _component = _colorComboBox;
        } else if (_property == DOTProperty.GROESSE) {
          aLabel = new JLabel("Schriftgröße: ");
          if (propertyValue != null) {
            _textSizeSpinner.setValue(propertyValue);
          }
          _component = _textSizeSpinner;
        } else if (_property == DOTProperty.STRICHBREITE) {
          aLabel = new JLabel("Strichbreite: ");
          if (propertyValue != null) {
            _strokeWidthSpinner.setValue(propertyValue);
          }
          _component = _strokeWidthSpinner;
        } else if (_property == DOTProperty.TEXT) {
          aLabel = new JLabel("Text: ");
          prepareTextComboBox(propertyValue);
          _component = _textComboBox;
        } else if (_property == DOTProperty.TEXTSTIL) {
          aLabel = new JLabel("Textstil: ");
          if (propertyValue != null) {
            _textStyleComboBox.setSelectedItem(propertyValue);
          }
          _component = _textStyleComboBox;
        } else if (_property == DOTProperty.TRANSPARENZ) {
          aLabel = new JLabel("Tranzparenz: ");
          if (propertyValue != null) {
            _transparencySpinner.setValue(propertyValue);
          }
          _component = _transparencySpinner;
        }
        panel.add(aLabel);
        panel.add(_component);

        panel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 0));
        SpringUtilities.makeCompactGrid(panel, 2, 20, 5);

        final JButton saveButton = new JButton("Speichern");
        saveButton.setEnabled(_dotDefinitionDialogFrame.isEditable());
        final JButton cancelButton = new JButton("Dialog schließen");

        final JPanel buttonsPanel = new JPanel();
        buttonsPanel.setLayout(new SpringLayout());

        buttonsPanel.add(saveButton);
        buttonsPanel.add(cancelButton);

        buttonsPanel.setBorder(BorderFactory.createEmptyBorder(5, 10, 5, 10));
        SpringUtilities.makeCompactGrid(buttonsPanel, 2, 20, 5);
        addButtonListeners(saveButton, cancelButton);

        setTitle("GND: Darstellungsfestlegung für Punkte");
        setLayout(new BorderLayout());
        add(new JScrollPane(panel), BorderLayout.NORTH);
        add(new JScrollPane(_dynamicDefinitionComponent), BorderLayout.CENTER);
        add(buttonsPanel, BorderLayout.SOUTH);
        pack();
        setSize(700, 550);
        final Rectangle bounds = getBounds();
        setLocation(
            new Point((int) (bounds.getHeight() / 1.5 + 300), (int) (bounds.getWidth() / 1.5)));
      }
Exemplo n.º 11
0
    public void paintComponent(Graphics g) {
      Rectangle selection = g.getClipBounds();

      // clear out the image
      Graphics2D g2 = (Graphics2D) g;
      g2.setBackground(backgroundColor);
      g2.clearRect(
          (int) selection.getX(),
          (int) selection.getY(),
          (int) selection.getWidth(),
          (int) selection.getHeight());

      // draw the selection if it exists
      if (selBeginPixel != -1 && selEndPixel != -1) {
        g2.setBackground(selectionColor);
        g2.clearRect(selBeginPixel, 0, selEndPixel - selBeginPixel + 1, this.getHeight());
      }

      if (this.points.size() > 0) {
        g2.setColor(waveColor);
        // draw the lines
        if (this.points.size() > stemThresh) {
          if (points.size() > frameWidth) { // draw contour
            // g2.setStroke(thickerStroke);
            for (int i = 0; i < this.points.size() - 1; i += 4) {
              Point2D.Float pt1 = points.get(i).getDispPoint();
              // Point2D.Float pt2  = new Point2D.Float(pt1.x, pt1.y/2);
              Point2D.Float pt2 = points.get(i + 1).getDispPoint();
              Point2D.Float pt3 = points.get(i + 2).getDispPoint();
              Point2D.Float pt4 = points.get(i + 3).getDispPoint();

              //							//Point2D.Float pt4  = new Point2D.Float(pt2.x, pt2.y/2);
              g2.draw(new Line2D.Float(pt1, pt2));
              // g2.setColor(waveLiteColor);
              g.setColor(waveLiteColor);
              g2.draw(new Line2D.Float(pt2, pt3));
              g2.setColor(waveColor);
              g2.draw(new Line2D.Float(pt3, pt4));
              //							g2.draw(new Line2D.Float(this.points.get(i).getDispPoint(),
              //									this.points.get(i+1).getDispPoint()));
              //							g2.draw(new Line2D.Float(this.points.get(i).getDispPoint(),
              //									this.points.get(i+1).getDispPoint()));
              //							g2.draw(new Line2D.Float(this.points.get(i).getDispPoint(),
              //									this.points.get(i+1).getDispPoint()));
            }

          } else { // draw line
            g2.setStroke(stroke);
            for (int i = 0; i < this.points.size() - 1; i++) {
              g2.draw(
                  new Line2D.Float(
                      this.points.get(i).getDispPoint(), this.points.get(i + 1).getDispPoint()));
            }
          }
        } else { // stem plot
          for (int i = 0; i < this.points.size(); i++) {
            // draw the stem
            SoundSample sample = this.points.get(i);
            g2.setStroke(thickerStroke);
            Point2D.Double base =
                new Point2D.Double(
                    sample.getDispPoint().getX() + 10, Math.floor(this.getHeight()) / 2);
            Point2D.Double pt =
                new Point2D.Double(sample.getDispPoint().getX() + 10, sample.getDispPoint().getY());
            g2.draw(new Line2D.Float(base, pt));

            if (this.points.size() < zoomThresh) {
              // draw the sample value
              float sampleValue = (float) sample.getSampleValue();
              float y = (float) sample.getDispPoint().getY();
              g2.setFont(textFont);
              if (y < Math.floor(this.getHeight()) / 2) y = y - 10;
              else y = y + 10;
              // if (sample.getDispPoint().getX() > 0)
              g2.drawString(formatter.format(sampleValue), (float) sample.getDispPoint().getX(), y);
            }

            // draw the vertical bar in the array
            //						g2.setStroke(thickerStroke);
            //						base = new Point2D.Double(base.getX()-8, this.getHeight() - 10);
            //						pt = new Point2D.Double(base.getX(), this.getHeight() - 50);
            //						g2.draw(new Line2D.Double(base, pt));
            //						g2.drawString(formatter.format(points.get(i).getSampleIndex()),
            // (float)base.getX(), (float)base.getY() - 10 );
          }
          //
          //					g2.setStroke(wideStroke);
          //					//draw the array cells
          //					g2.draw(new Line2D.Double(selection.getX(),
          //							Math.floor(this.getHeight() - 30),
          //							selection.getX()+selection.getWidth()-1,
          //							Math.floor(this.getHeight() - 30)));
          //					//draw the array cells
          //					g2.draw(new Line2D.Double(selection.getX(),
          //							Math.floor(this.getHeight() - 10),
          //							selection.getX()+selection.getWidth()-1,
          //							Math.floor(this.getHeight() - 10)));
        }
      }

      // draw the center line
      g2.setColor(barColor);
      g2.setStroke(new BasicStroke(1));
      g2.draw(
          new Line2D.Double(
              selection.getX(),
              Math.floor(this.getHeight() / 2),
              selection.getX() + selection.getWidth() - 1,
              Math.floor(this.getHeight() / 2)));

      //			//draw the current position
      //			if (selection.getX()<currentPixelPosition &&
      //					currentPixelPosition<(selection.getX()+selection.getWidth()-1))
      //			{
      //				g2.setColor(barColor);
      //				g2.setStroke(new BasicStroke(1));
      //				g2.draw(new Line2D.Double(currentPixelPosition, 0,
      //						currentPixelPosition, frameHeight));
      //			}
    }
Exemplo n.º 12
0
    @Override
    protected void paintComponent(Graphics g) {
      JRibbonFrame ribbonFrame = (JRibbonFrame) SwingUtilities.getWindowAncestor(this);
      if (!ribbonFrame.isShowingKeyTips()) return;

      // don't show keytips on inactive windows
      if (!ribbonFrame.isActive()) return;

      Collection<KeyTipManager.KeyTipLink> keyTips =
          KeyTipManager.defaultManager().getCurrentlyShownKeyTips();
      if (keyTips != null) {
        Graphics2D g2d = (Graphics2D) g.create();
        RenderingUtils.installDesktopHints(g2d);

        for (KeyTipManager.KeyTipLink keyTip : keyTips) {
          // don't display keytips on components in popup panels
          if (SwingUtilities.getAncestorOfClass(JPopupPanel.class, keyTip.comp) != null) continue;

          // don't display key tips on hidden components
          Rectangle compBounds = keyTip.comp.getBounds();
          if (!keyTip.comp.isShowing()
              || (compBounds.getWidth() == 0)
              || (compBounds.getHeight() == 0)) continue;

          Dimension pref =
              KeyTipRenderingUtilities.getPrefSize(g2d.getFontMetrics(), keyTip.keyTipString);

          Point prefCenter = keyTip.prefAnchorPoint;
          Point loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, this);
          Container bandControlPanel =
              SwingUtilities.getAncestorOfClass(AbstractBandControlPanel.class, keyTip.comp);
          if (bandControlPanel != null) {
            // special case for controls in threesome
            // ribbon band rows
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.TOP_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = 0;
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = 0;
            }
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.MID_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = bandControlPanel.getHeight() / 2;
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = keyTip.comp.getHeight() / 2;
            }
            if (hasClientPropertySetToTrue(keyTip.comp, BasicBandControlPanelUI.BOTTOM_ROW)) {
              loc = SwingUtilities.convertPoint(keyTip.comp, prefCenter, bandControlPanel);
              loc.y = bandControlPanel.getHeight();
              loc = SwingUtilities.convertPoint(bandControlPanel, loc, this);
              // prefCenter.y = keyTip.comp.getHeight();
            }
          }

          KeyTipRenderingUtilities.renderKeyTip(
              g2d,
              this,
              new Rectangle(
                  loc.x - pref.width / 2, loc.y - pref.height / 2, pref.width, pref.height),
              keyTip.keyTipString,
              keyTip.enabled);
        }

        g2d.dispose();
      }
    }