Java Code Examples for java.awt.Rectangle#getHeight()

The following examples show how to use java.awt.Rectangle#getHeight() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ImageUtils.java    From hifive-pitalium with Apache License 2.0 6 votes vote down vote up
/**
 * if the given rectangle may occur raster error, reshape it
 *
 * @param rectangle Rectangle which will be reshaped
 * @param xLimit limit of x+width of given rectangle
 * @param yLimit limit of y+height of given rectangle
 */
public static void reshapeRect(Rectangle rectangle, int xLimit, int yLimit) {
	double width = rectangle.getWidth(), height = rectangle.getHeight();
	double x = rectangle.getX(), y = rectangle.getY();

	if (x < 0) {
		width += x;
		x = 0;
	}
	if (y < 0) {
		height += y;
		y = 0;
	}

	if (x + width >= xLimit)
		width = xLimit - x;
	if (y + height >= yLimit)
		height = yLimit - y;

	rectangle.setRect(x, y, Math.max(width, 1), Math.max(height, 1));
}
 
Example 2
Source File: OptionsDisplayerImpl.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private Point getUserLocation(GraphicsConfiguration gconf, OptionsPanel optionsPanel) {
      final Rectangle screenBounds = Utilities.getUsableScreenBounds(gconf);
      int x = NbPreferences.forModule(OptionsDisplayerImpl.class).getInt("OptionsX", Integer.MAX_VALUE);//NOI18N
      int y = NbPreferences.forModule(OptionsDisplayerImpl.class).getInt("OptionsY", Integer.MAX_VALUE);//NOI18N
      Dimension userSize = optionsPanel.getUserSize();
      if (x > screenBounds.x + screenBounds.getWidth() || y > screenBounds.y + screenBounds.getHeight()
              || x + userSize.width > screenBounds.x + screenBounds.getWidth() 
              || y + userSize.height > screenBounds.y + screenBounds.getHeight()
              || (x < screenBounds.x && screenBounds.x >= 0)
|| (x > screenBounds.x && screenBounds.x < 0)
|| (y < screenBounds.y && screenBounds.y >= 0)
|| (y > screenBounds.y && screenBounds.y < 0)){
          return null;
      } else {
          return new Point(x, y);
      }
  }
 
Example 3
Source File: ConnectableView.java    From PIPE with MIT License 5 votes vote down vote up
/**
     * Changes the displayed bounds of the object relative to its x,y width and height
     *
     * Implemented because the canvas has no layout manager
     *
     */
    protected final void updateBounds() {
        Rectangle bounds = shape.getBounds();
        Rectangle newBounds = new Rectangle((int)(model.getCentre().getX() + bounds.getX()), (int)(model.getCentre().getY() + bounds.getY()), (int) bounds.getWidth() + getComponentDrawOffset(), (int)bounds.getHeight() + getComponentDrawOffset()) ;
        setBounds(newBounds);
//        setBounds(model.getX(), model.getY(), model.getWidth() + getComponentDrawOffset(), model.getHeight() + getComponentDrawOffset());

        //TODO: THIS IS A DIRTY HACK IN ORDER TO GET DRAGGIGN WHEN ZOOMED WORKING
        Component root = SwingUtilities.getRoot(this);
        if (root != null) {
            root.repaint();
        }
    }
 
Example 4
Source File: ShowUsagesAction.java    From dagger-intellij-plugin with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 5
Source File: PolygonDrawPanel.java    From jclic with GNU General Public License v2.0 5 votes vote down vote up
protected void paintDrawnBorders(java.awt.Graphics2D g) {
  for (Rectangle r : vDrawnBorders) {
    double x = r.getX();
    double y = r.getY();
    double w = r.getWidth();
    double h = r.getHeight();
    x = x + (w / 4);
    y = y + (h / 4);
    w = w / 2;
    h = h / 2;
    g.setColor(EditableShapeConstants.DRAWN_BORDER_COLOR);
    g.fillRect((int) x, (int) y, (int) w, (int) h);
  }
}
 
Example 6
Source File: ExportImageAction.java    From snap-desktop with GNU General Public License v3.0 5 votes vote down vote up
private static void setTransform(Viewport vp1, Viewport vp2) {
    vp2.setTransform(vp1);

    final Rectangle rectangle1 = vp1.getViewBounds();
    final Rectangle rectangle2 = vp2.getViewBounds();

    final double w1 = rectangle1.getWidth();
    final double w2 = rectangle2.getWidth();
    final double h1 = rectangle1.getHeight();
    final double h2 = rectangle2.getHeight();
    final double x1 = rectangle1.getX();
    final double y1 = rectangle1.getY();
    final double cx = (x1 + w1) / 2.0;
    final double cy = (y1 + h1) / 2.0;

    final double magnification;
    if (w1 > h1) {
        magnification = w2 / w1;
    } else {
        magnification = h2 / h1;
    }

    final Point2D modelCenter = vp1.getViewToModelTransform().transform(new Point2D.Double(cx, cy), null);
    final double zoomFactor = vp1.getZoomFactor() * magnification;
    if (zoomFactor > 0.0) {
        vp2.setZoomFactor(zoomFactor, modelCenter.getX(), modelCenter.getY());
    }
}
 
Example 7
Source File: GlobalUtils.java    From aurous-app with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Center a frame on the main display
 *
 * @param frame
 *            The frame to center
 */
public void centerFrameOnMainDisplay(final JFrame frame) {
	final GraphicsEnvironment ge = GraphicsEnvironment
			.getLocalGraphicsEnvironment();
	final GraphicsDevice[] screens = ge.getScreenDevices();
	if (screens.length < 1) {
		return; // Silently fail.
	}
	final Rectangle screenBounds = screens[0].getDefaultConfiguration()
			.getBounds();
	final int x = (int) ((screenBounds.getWidth() - frame.getWidth()) / 2);
	final int y = (int) ((screenBounds.getHeight() - frame.getHeight()) / 2);
	frame.setLocation(x, y);
}
 
Example 8
Source File: AbstractVisualGraphTest.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Moves the given vertex as necessary so that it is not touching any other vertex
 * 
 * @param v the vertex
 */
protected void isolateVertex(AbstractTestVertex v) {
	GraphViewer<AbstractTestVertex, TestEdge> viewer = graphComponent.getPrimaryViewer();
	Layout<AbstractTestVertex, TestEdge> layout = viewer.getGraphLayout();
	Rectangle vBounds = GraphViewerUtils.getVertexBoundsInLayoutSpace(viewer, v);

	boolean hit = false;
	Collection<AbstractTestVertex> others = new HashSet<>(graph.getVertices());
	others.remove(v);
	for (AbstractTestVertex other : others) {
		Rectangle otherBounds = GraphViewerUtils.getVertexBoundsInLayoutSpace(viewer, other);
		if (vBounds.intersects(otherBounds)) {
			hit = true;
			Point p = vBounds.getLocation();
			int w = (int) vBounds.getWidth();
			int h = (int) vBounds.getHeight();
			Point newPoint = new Point(p.x + w, p.y + h);
			swing(() -> layout.setLocation(v, newPoint));
			viewer.repaint();
			sleep(50); // let us see the effect
			waitForSwing();
		}
	}

	if (hit) {
		// keep moving until we are clear of other vertices
		isolateVertex(v);
	}
}
 
Example 9
Source File: CanvasPane.java    From Logisim with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void propertyChange(PropertyChangeEvent e) {
	String prop = e.getPropertyName();
	if (prop.equals(ZoomModel.ZOOM)) {
		// mouse point
		Point point = getMousePosition(true);
		double oldZoom = ((Double) e.getOldValue()).doubleValue();
		Rectangle r = getViewport().getViewRect();
		double cx = (r.getX() + r.getWidth() / 2) / oldZoom;
		double cy = (r.getY() + r.getHeight() / 2) / oldZoom;

		double newZoom = ((Double) e.getNewValue()).doubleValue();
		r = getViewport().getViewRect();
		if (point != null) {// mouse is pointing something
			int newX = (int) Math
					.round(r.getX() / oldZoom * newZoom + point.getX() / oldZoom * newZoom - point.getX());
			int newY = (int) Math
					.round(r.getY() / oldZoom * newZoom + point.getY() / oldZoom * newZoom - point.getY());
			getHorizontalScrollBar().setValue(newX);
			getVerticalScrollBar().setValue(newY);
		} else {// mouse is outside from canvas panel
			int hv = (int) (cx * newZoom - r.getWidth() / 2);
			int vv = (int) (cy * newZoom - r.getHeight() / 2);
			getHorizontalScrollBar().setValue(hv);
			getVerticalScrollBar().setValue(vv);
		}
		contents.recomputeSize();
	}
}
 
Example 10
Source File: AbstractDataView.java    From ET_Redux with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param bounds
 * @param leftMargin
 * @param topMargin
 */
protected AbstractDataView(Rectangle bounds, int leftMargin, int topMargin) {
    super();
    this.leftMargin = leftMargin;
    this.topMargin = topMargin;

    this.myOnPeakData = null;

    width = bounds.getWidth();
    height = bounds.getHeight();
    graphWidth = (int) width - leftMargin;
    graphHeight = (int) height - topMargin;

    this.ticsYaxis = new BigDecimal[0];
    this.ticsXaxis = new BigDecimal[0];

    this.eastResizing = false;
    this.southResizing = false;

    this.zoomCount = 0;

    putInImageModePan();

    this.showCenters = true;
    this.showLabels = false;

    this.showMe = true;

    addMeAsMouseListener();
}
 
Example 11
Source File: OverviewPanel.java    From rapidminer-studio with GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
protected void paintComponent(Graphics graphics) {
	super.paintComponent(graphics);
	double scaleX = (double) getWidth() / (double) processRenderer.getWidth();
	double scaleY = (double) getHeight() / (double) processRenderer.getHeight();
	scale = Math.min(scaleX, scaleY);
	double scaledW = processRenderer.getWidth() * scale;
	double scaledH = processRenderer.getHeight() * scale;

	Graphics2D g = (Graphics2D) graphics.create();
	g.translate((getWidth() - scaledW) / 2d, (getHeight() - scaledH) / 2d);
	g.scale(scale, scale);

	g.setRenderingHints(ProcessDrawer.LOW_QUALITY_HINTS);
	processRenderer.getOverviewPanelDrawer().draw(g, true);

	g.setStroke(new BasicStroke((int) (1d / scale)));

	Rectangle visibleRect = processRenderer.getVisibleRect();
	Rectangle drawRect = new Rectangle((int) visibleRect.getX(), (int) visibleRect.getY(),
			(int) visibleRect.getWidth() - 1, (int) visibleRect.getHeight() - 1);

	g.setColor(FILL_COLOR);
	g.fill(drawRect);

	g.setColor(DRAW_COLOR);
	g.draw(drawRect);

	g.dispose();
}
 
Example 12
Source File: ButtonCellRenderer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellRendererComponent (
    JTable table, Object value,
    boolean isSelected, boolean hasFocus, int row, int column
) {
    JLabel c = (JLabel)defaultRenderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
    
    if (value instanceof String) {
        Rectangle cellRect = table.getCellRect(row, column, false);
        String scCell = (String) value;
        Dimension d = new Dimension((int) cellRect.getWidth(), (int) cellRect.getHeight());
        if (panel == null)
            panel = new ShortcutCellPanel(scCell);
        panel.setText(scCell);
        panel.setSize(d);

        if (isSelected) {
            panel.setBgColor(table.getSelectionBackground());
            if (UIManager.getLookAndFeel ().getID ().equals ("GTK"))
                panel.setFgCOlor(table.getForeground(), true);
            else
                panel.setFgCOlor(table.getSelectionForeground(), true);
        } else {
            panel.setBgColor(c.getBackground());
            panel.setFgCOlor(c.getForeground(), false);
        }
        if (hasFocus) {
            panel.setBorder(c.getBorder());
        } else {
            panel.setBorder(null);
        }

        return panel;
    }
    else {
        return c;
    }
}
 
Example 13
Source File: Utils.java    From aurous-app with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Center a frame on the main display
 *
 * @param frame
 *            The frame to center
 */
public static void centerFrameOnMainDisplay(final JFrame frame) {
	final GraphicsEnvironment ge = GraphicsEnvironment
			.getLocalGraphicsEnvironment();
	final GraphicsDevice[] screens = ge.getScreenDevices();
	if (screens.length < 1) {
		return; // Silently fail.
	}
	final Rectangle screenBounds = screens[0].getDefaultConfiguration()
			.getBounds();
	final int x = (int) ((screenBounds.getWidth() - frame.getWidth()) / 2);
	final int y = (int) ((screenBounds.getHeight() - frame.getHeight()) / 2);
	frame.setLocation(x, y);
}
 
Example 14
Source File: DefaultOutlineCellRenderer.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Override
public void paintBorder(Component c, java.awt.Graphics g, int x, int y, int width, int height) {
    DefaultOutlineCellRenderer ren = (DefaultOutlineCellRenderer)
            ((JComponent) c).getClientProperty(DefaultOutlineCellRenderer.class);
    if (ren == null) {
        ren = (DefaultOutlineCellRenderer) c;
    }
    if (ren.isShowHandle() && !ren.isLeaf()) {
        Icon icon = ren.isExpanded() ? getExpandedIcon() : getCollapsedIcon();
        int iconY;
        int iconX = ren.getNestingDepth() * getNestingWidth();
        if (icon.getIconHeight() < height) {
            iconY = (height / 2) - (icon.getIconHeight() / 2);
        } else {
            iconY = 0;
        }
        if (isNimbus) {
            iconX += icon.getIconWidth()/3; // To look good
        }
        if (isGtk) {
            JLabel lbl = ren.isExpanded () ? lExpandedIcon : lCollapsedIcon;
            lbl.setSize (Math.max (getExpansionHandleWidth (), iconX + getExpansionHandleWidth ()), height);
            lbl.paint (g);
        } else {
            icon.paintIcon(c, g, iconX, iconY);
        }
    }
    JCheckBox chBox = ren.getCheckBox();
    if (chBox != null) {
        int chBoxX = getExpansionHandleWidth() + ren.getNestingDepth() * getNestingWidth();
        Rectangle bounds = chBox.getBounds();
        int chBoxY;
        if (bounds.getHeight() < height) {
            chBoxY = (height / 2) - (((int) bounds.getHeight()) / 2);
        } else {
            if (isNimbus) {
                chBoxY = 1;
            } else {
                chBoxY = 0;
            }
        }
        Dimension chDim = chBox.getSize();
        java.awt.Graphics gch = g.create(chBoxX, chBoxY, chDim.width, chDim.height);
        chBox.paint(gch);
    }
}
 
Example 15
Source File: JobInformation.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
public void drawImage( final Graphics2D g2d, final Rectangle2D rectangle2d, ReportSubjectLocation location,
  boolean pixelateImages ) throws KettleException {

  // Load the job
  //
  JobMeta jobMeta = loadJob( location );

  Point min = jobMeta.getMinimum();
  Point area = jobMeta.getMaximum();

  area.x -= min.x;
  area.y -= min.y;

  int iconsize = 32;

  ScrollBarInterface bar = new ScrollBarInterface() {
    public void setThumb( int thumb ) {
    }

    public int getSelection() {
      return 0;
    }
  };

  // Paint the transformation...
  //
  Rectangle rect = new java.awt.Rectangle( 0, 0, area.x, area.y );
  double magnificationX = rectangle2d.getWidth() / rect.getWidth();
  double magnificationY = rectangle2d.getHeight() / rect.getHeight();
  float magnification = (float) Math.min( 1, Math.min( magnificationX, magnificationY ) );

  SwingGC gc = new SwingGC( g2d, rect, iconsize, 0, 0 );
  gc.setDrawingPixelatedImages( pixelateImages );
  List<AreaOwner> areaOwners = new ArrayList<AreaOwner>();
  JobPainter painter =
      new JobPainter( gc, jobMeta, area, bar, bar, null, null, null, areaOwners, new ArrayList<JobEntryCopy>(),
          iconsize, 1, 0, 0, true, "FreeSans", 10 );

  painter.setMagnification( magnification );

  painter.setTranslationX( ( -min.x ) * magnification );
  painter.setTranslationY( ( -min.y ) * magnification );

  painter.drawJob();
}
 
Example 16
Source File: SkinEditorMainGUI.java    From megamek with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Initializes a number of things about this frame.
 */
private void initializeFrame() {
    frame = new JFrame(Messages.getString("ClientGUI.title")); //$NON-NLS-1$
    frame.setJMenuBar(menuBar);
    Rectangle virtualBounds = getVirtualBounds();
    int x, y, w, h;
    if (GUIPreferences.getInstance().getWindowSizeHeight() != 0) {
        x = GUIPreferences.getInstance().getWindowPosX();
        y = GUIPreferences.getInstance().getWindowPosY();
        w = GUIPreferences.getInstance().getWindowSizeWidth();
        h = GUIPreferences.getInstance().getWindowSizeHeight();
        if ((x < virtualBounds.getMinX())
                || ((x + w) > virtualBounds.getMaxX())) {
            x = 0;
        }
        if ((y < virtualBounds.getMinY())
                || ((y + h) > virtualBounds.getMaxY())) {
            y = 0;
        }
        if (w > virtualBounds.getWidth()) {
            w = (int) virtualBounds.getWidth();
        }
        if (h > virtualBounds.getHeight()) {
            h = (int) virtualBounds.getHeight();
        }
        frame.setLocation(x, y);
        frame.setSize(w, h);
    } else {
        frame.setSize(800, 600);
    }
    frame.setMinimumSize(new Dimension(640, 480));
    frame.setBackground(SystemColor.menu);
    frame.setForeground(SystemColor.menuText);
    List<Image> iconList = new ArrayList<Image>();
    iconList.add(frame.getToolkit().getImage(
            new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_16X16)
                    .toString()));
    iconList.add(frame.getToolkit().getImage(
            new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_32X32)
                    .toString()));
    iconList.add(frame.getToolkit().getImage(
            new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_48X48)
                    .toString()));
    iconList.add(frame.getToolkit().getImage(
            new MegaMekFile(Configuration.miscImagesDir(), FILENAME_ICON_256X256)
                    .toString()));
    frame.setIconImages(iconList);

    mechW = new JDialog(frame, Messages.getString("ClientGUI.MechDisplay"), false);
    x = GUIPreferences.getInstance().getDisplayPosX();
    y = GUIPreferences.getInstance().getDisplayPosY();
    h = GUIPreferences.getInstance().getDisplaySizeHeight();
    w = GUIPreferences.getInstance().getDisplaySizeWidth();
    if ((x + w) > virtualBounds.getWidth()) {
        x = 0;
        w = Math.min(w, (int)virtualBounds.getWidth());
    }
    if ((y + h) > virtualBounds.getHeight()) {
        y = 0;
        h = Math.min(h, (int)virtualBounds.getHeight());
    }
    mechW.setLocation(x, y);
    mechW.setSize(w, h);
    mechW.setResizable(true);
    unitDisplay = new UnitDisplay(null);
    mechW.add(unitDisplay);
    mechW.setVisible(true);
    unitDisplay.displayEntity(testEntity);
}
 
Example 17
Source File: AMCChecker.java    From PUMA with Apache License 2.0 4 votes vote down vote up
public void run() {
	UiHierarchyXmlLoader loader = new UiHierarchyXmlLoader();
	BasicTreeNode root = loader.parseXml(fn);

	// make 1 pass to get list of all buttons and check scrolling on the fly
	List<Rectangle> allButtons = new ArrayList<Rectangle>();
	boolean scrolling_violation = false;

	Queue<BasicTreeNode> Q = new LinkedList<BasicTreeNode>();
	Q.add(root);

	while (!Q.isEmpty()) {
		BasicTreeNode btn = Q.poll();

		if (btn instanceof UiNode) {
			UiNode uinode = (UiNode) btn;

			String clz = uinode.getAttribute("class");
			boolean enabled = Boolean.parseBoolean(uinode.getAttribute("enabled"));
			boolean scrolling = Boolean.parseBoolean(uinode.getAttribute("scrollable"));

			if (clz.contains("Button") && enabled) {
				Rectangle bounds = new Rectangle(uinode.x, uinode.y, uinode.width, uinode.height);
				allButtons.add(bounds);
				// Util.log("Found button: " + bounds + " --> " + clz);
			}

			if (scrolling && !scrolling_violation) {
				scrolling_violation = true;
			}
		}

		for (BasicTreeNode child : btn.getChildren()) {
			Q.add(child);
		}
	}

	int btn_size_violation = 0;
	int btn_dist_violation = 0;

	for (int i = 0; i < allButtons.size(); i++) {
		Rectangle b1 = allButtons.get(i);
		double area = b1.getWidth() * b1.getHeight();

		if (area < BTN_SIZE_DICT.get(dev)) {
			// Util.log(b1 + ": " + area);
			btn_size_violation++;
		}

		for (int j = i + 1; j < allButtons.size(); j++) {
			Rectangle b2 = allButtons.get(j);

			double d = get_distance(b1, b2);
			if (d < BTN_DIST_DICT.get(dev)) {
				// Util.log(b1 + " --> " + b2 + ": " + d);
				btn_dist_violation++;
			}
		}
	}

	System.out.println(btn_size_violation + "," + btn_dist_violation + "," + (scrolling_violation ? 1 : 0));
}
 
Example 18
Source File: DocumentaryTransition2D.java    From pumpernickel with MIT License 4 votes vote down vote up
@Override
public Transition2DInstruction[] getInstructions(float progress,
		Dimension size) {

	Rectangle r1 = new Rectangle(0, 0, size.width, size.height);
	float k1 = .6f;
	float k2 = .95f - k1;
	float k3 = (1 - k1) / 2;

	float cutOff = .4f;
	Rectangle2D r2;
	if (type == RIGHT) {
		r2 = new Rectangle2D.Float(k2 * r1.width, k3 * r1.height, k1
				* r1.width, k1 * r1.height);
	} else if (type == LEFT) {
		r2 = new Rectangle2D.Float(.05f * r1.width, k3 * r1.height, k1
				* r1.width, k1 * r1.height);
	} else if (type == DOWN) {
		r2 = new Rectangle2D.Float(k3 * r1.width, k2 * r1.height, k1
				* r1.width, k1 * r1.height);
	} else { // up
		r2 = new Rectangle2D.Float(k3 * r1.width, .05f * r1.height, k1
				* r1.width, k1 * r1.height);
	}
	float zoomProgress;
	float panProgress = (float) (.5 + .5 * Math.sin(Math.PI
			* (progress * progress - .5)));
	if (progress < cutOff) {
		// we're zooming in
		zoomProgress = progress / cutOff;
	} else {
		zoomProgress = 1;
	}

	Rectangle2D r3 = new Rectangle2D.Float((float) (r2.getX()
			* (1 - panProgress) + r1.getX() * panProgress),
			(float) (r2.getY() * (1 - panProgress) + r1.getY()
					* panProgress), (float) (r2.getWidth()
					* (1 - panProgress) + r1.getWidth() * panProgress),
			(float) (r2.getHeight() * (1 - panProgress) + r1.getHeight()
					* panProgress));

	List<Transition2DInstruction> v = new ArrayList<Transition2DInstruction>();

	AffineTransform t = RectangularTransform.create(r3, r1);
	v.add(new ImageInstruction(false, t, r1));

	if (zoomProgress != 1) {
		v.add(new ImageInstruction(true, 1 - zoomProgress));
	}

	return v.toArray(new Transition2DInstruction[v.size()]);
}
 
Example 19
Source File: UiUtils.java    From pgptool with GNU General Public License v3.0 4 votes vote down vote up
private static String format(Rectangle bounds) {
	return "x=" + (int) bounds.getX() + ",y=" + (int) bounds.getY() + ",w=" + (int) bounds.getWidth() + ",h="
			+ (int) bounds.getHeight();
}
 
Example 20
Source File: Utils.java    From Quelea with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Converts an AWT rectangle to a JavaFX bounds object.
 * <p/>
 * @param rect the rectangle to convert.
 * @return the equivalent bounds.
 */
public static Bounds getBoundsFromRect(Rectangle rect) {
	return new BoundingBox(rect.getX(), rect.getY(), rect.getWidth(), rect.getHeight());
}