java.awt.Rectangle Java Examples

The following examples show how to use java.awt.Rectangle. 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: SynthTableUI.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private Rectangle extendRect(Rectangle rect, boolean horizontal) {
    if (rect == null) {
        return rect;
    }

    if (horizontal) {
        rect.x = 0;
        rect.width = table.getWidth();
    } else {
        rect.y = 0;

        if (table.getRowCount() != 0) {
            Rectangle lastRect = table.getCellRect(table.getRowCount() - 1, 0, true);
            rect.height = lastRect.y + lastRect.height;
        } else {
            rect.height = table.getHeight();
        }
    }

    return rect;
}
 
Example #2
Source File: CardFlowPanel.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
private void drawActiveImage(final Graphics2D g2d, final int activeSlotIndex) {

        final Rectangle startRect = flowDirection == FlowDirection.RIGHT
                ? slots.get(activeSlotIndex - 1)
                : slots.get(activeSlotIndex + 1);

        final Rectangle endRect = slots.get(activeSlotIndex);

        final int adjX = (int)((startRect.x - endRect.x) * timelinePulse);
        final int adjX2 = (int)(getBellShapedFunctionB(timelinePulse));

        final Rectangle imageRect = new Rectangle(
                (startRect.x - adjX) + (flowDirection == FlowDirection.LEFT ? adjX2 : -adjX2),
                0,
                startRect.width + (int) ((endRect.width - startRect.width) * timelinePulse),
                startRect.height + (int) ((endRect.height - startRect.height) * timelinePulse)
        );

        BufferedImage image = ImageHelper.scale(
            getImage(activeImageIndex), imageRect.width, imageRect.height
        );
        g2d.drawImage(image, imageRect.x, imageRect.y, null);

    }
 
Example #3
Source File: CloseTabPaneUI.java    From iBioSim with Apache License 2.0 6 votes vote down vote up
public void scrollForward(int tabPlacement) {
	Dimension viewSize = viewport.getViewSize();
	Rectangle viewRect = viewport.getViewRect();

	if (tabPlacement == TOP || tabPlacement == BOTTOM) {
		if (viewRect.width >= viewSize.width - viewRect.x) {
			return; // no room left to scroll
		}
	}
	else { // tabPlacement == LEFT || tabPlacement == RIGHT
		if (viewRect.height >= viewSize.height - viewRect.y) {
			return;
		}
	}
	setLeadingTabIndex(leadingTabIndex + 1);
}
 
Example #4
Source File: WPrinterJob.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
private void init(Component parent, String  title, String message,
                  String buttonText) {
    Panel p = new Panel();
    add("Center", new Label(message));
    Button btn = new Button(buttonText);
    btn.addActionListener(this);
    p.add(btn);
    add("South", p);
    pack();

    Dimension dDim = getSize();
    if (parent != null) {
        Rectangle fRect = parent.getBounds();
        setLocation(fRect.x + ((fRect.width - dDim.width) / 2),
                    fRect.y + ((fRect.height - dDim.height) / 2));
    }
}
 
Example #5
Source File: AquaTabbedPaneContrastUI.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
protected void paintTitle(final Graphics2D g2d, final Font font, final FontMetrics metrics, final Rectangle textRect, final int tabIndex, final String title) {
    final View v = getTextViewForTab(tabIndex);
    if (v != null) {
        v.paint(g2d, textRect);
        return;
    }

    if (title == null) return;

    final Color color = tabPane.getForegroundAt(tabIndex);
    if (color instanceof UIResource) {
        g2d.setColor(getNonSelectedTabTitleColor());
        if (tabPane.getSelectedIndex() == tabIndex) {
            boolean pressed = isPressedAt(tabIndex);
            boolean enabled = tabPane.isEnabled() && tabPane.isEnabledAt(tabIndex);
            Color textColor = getSelectedTabTitleColor(enabled, pressed);
            Color shadowColor = getSelectedTabTitleShadowColor(enabled);
            AquaUtils.paintDropShadowText(g2d, tabPane, font, metrics, textRect.x, textRect.y, 0, 1, textColor, shadowColor, title);
            return;
        }
    } else {
        g2d.setColor(color);
    }
    g2d.setFont(font);
    SwingUtilities2.drawString(tabPane, g2d, title, textRect.x, textRect.y + metrics.getAscent());
}
 
Example #6
Source File: XComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
public void coalescePaintEvent(PaintEvent e) {
    Rectangle r = e.getUpdateRect();
    if (!(e instanceof IgnorePaintEvent)) {
        paintArea.add(r, e.getID());
    }
    if (true) {
        switch(e.getID()) {
          case PaintEvent.UPDATE:
              if (log.isLoggable(PlatformLogger.Level.FINER)) {
                  log.finer("XCP coalescePaintEvent : UPDATE : add : x = " +
                        r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
              }
              return;
          case PaintEvent.PAINT:
              if (log.isLoggable(PlatformLogger.Level.FINER)) {
                  log.finer("XCP coalescePaintEvent : PAINT : add : x = " +
                        r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
              }
              return;
        }
    }
}
 
Example #7
Source File: TimelineApplet.java    From universal-tween-engine with Apache License 2.0 6 votes vote down vote up
public MyCanvas() {
	Tween.enablePooling(false);
	Tween.registerAccessor(Sprite.class, new SpriteAccessor());
	
	imgUniversalSprite = new Sprite("img-universal.png").setCentered(false);
	imgTweenSprite = new Sprite("img-tween.png").setCentered(false);
	imgEngineSprite = new Sprite("img-engine.png").setCentered(false);
	imgLogoSprite = new Sprite("img-logo.png");
	blankStripSprite = new Sprite("blankStrip.png");

	try {
		BufferedImage bgImage = ImageIO.read(TimelineApplet.class.getResource("/aurelienribon/tweenengine/applets/gfx/transparent-dark.png"));
		bgPaint = new TexturePaint(bgImage, new Rectangle(0, 0, bgImage.getWidth(), bgImage.getHeight()));
	} catch (IOException ex) {
	}
}
 
Example #8
Source File: baseDrawerItem.java    From brModelo with GNU General Public License v3.0 6 votes vote down vote up
public void DrawImagem(Graphics2D g) {
    BufferedImage img = getImagem();
    if (img == null) {
        return;
    }
    int[] pts = ArrayDePontos(getPosiImagem());
    if (pts.length != 4) {
        posiImagem = "L,T,200,200";
        imgres = null;
        pts = ArrayDePontos(getPosiImagem());
    }
    Rectangle rec = new Rectangle(pts[0], pts[1], pts[2], pts[3]);
    rec.grow(-2, -2);
    if (imgres == null) {
        imgres = img.getScaledInstance(rec.width, rec.height, Image.SCALE_SMOOTH);
    }
    g.drawImage(imgres, rec.x, rec.y, null);
}
 
Example #9
Source File: JIntellitypeDemo.java    From jintellitype with Apache License 2.0 6 votes vote down vote up
/**
 * Centers window on desktop.
 * <p>
 * 
 * @param aFrame the Frame to center
 */
private static void center(JFrame aFrame) {
	final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
	final Point centerPoint = ge.getCenterPoint();
	final Rectangle bounds = ge.getMaximumWindowBounds();
	final int w = Math.min(aFrame.getWidth(), bounds.width);
	final int h = Math.min(aFrame.getHeight(), bounds.height);
	final int x = centerPoint.x - (w / 2);
	final int y = centerPoint.y - (h / 2);
	aFrame.setBounds(x, y, w, h);
	if ((w == bounds.width) && (h == bounds.height)) {
		aFrame.setExtendedState(Frame.MAXIMIZED_BOTH);
	}
	aFrame.validate();
}
 
Example #10
Source File: SunGraphics2D.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Intersects <code>destRect</code> with <code>clip</code> and
 * overwrites <code>destRect</code> with the result.
 * Returns false if the intersection was empty, true otherwise.
 */
private boolean clipTo(Rectangle destRect, Rectangle clip) {
    int x1 = Math.max(destRect.x, clip.x);
    int x2 = Math.min(destRect.x + destRect.width, clip.x + clip.width);
    int y1 = Math.max(destRect.y, clip.y);
    int y2 = Math.min(destRect.y + destRect.height, clip.y + clip.height);
    if (((x2 - x1) < 0) || ((y2 - y1) < 0)) {
        destRect.width = -1; // Set both just to be safe
        destRect.height = -1;
        return false;
    } else {
        destRect.x = x1;
        destRect.y = y1;
        destRect.width = x2 - x1;
        destRect.height = y2 - y1;
        return true;
    }
}
 
Example #11
Source File: ResultPanel.java    From Pixie with MIT License 6 votes vote down vote up
/**
 * Merges the given object map in the image object map, at the specified
 * coordinates.
 *
 * @param newObjMap - the object map that has to be merged in the result map
 * @param pos       - the position where the image has to be copied: info x - the top-left X coordinate where the image has to be copied info; y - the top-left Y coordinate where the image has to be copied info; width - the width of the image to be copied info; height - the height of the image to be copied
 * @param objId     - the object id as byte value (it is obtained by computing the image object id % 255)
 * @param mergeBkg  - true if both the background and object have to overwrite the existent content of the object map; false if only the object should be merged
 */
public void mergeCrop(byte[][] newObjMap, Rectangle pos, long objId, boolean mergeBkg) {
    byte mapId = getByteObjId(objId);

    // update objectMap
    for (int y = 0; y < pos.getHeight(); y++) {
        for (int x = 0; x < pos.getWidth(); x++) {

            if (mergeBkg) {
                // merge bakground in object map (overwrites the initial byte, no matter what was storred, with bkg)
                objMap[x + pos.x][y + pos.y] = (newObjMap[x][y] > 0) ? mapId : (byte) 0;

            } else {
                // merge just the pure object - when the pixel in the  object map is != 0
                objMap[x + pos.x][y + pos.y] = ((objMap[x + pos.x][y + pos.y] == mapId) && (newObjMap[x][y] == 0)) ? 0 : objMap[x + pos.x][y + pos.y];
                objMap[x + pos.x][y + pos.y] = (newObjMap[x][y] > 0) ? mapId : objMap[x + pos.x][y + pos.y];
            }
        }
    }
}
 
Example #12
Source File: OracleText.java    From magarena with GNU General Public License v3.0 6 votes vote down vote up
private static SortedMap<Float, TextLayout> fitTextLayout(
    AttributedString attrString,
    Font font,
    FontRenderContext frc,
    Rectangle box,
    int leftPadding,
    int topPadding
) {
    // decrease font by 0.5 points each time until lines can fit
    SortedMap<Float, TextLayout> lines = new TreeMap<>();
    Font f = font;
    while (lines.isEmpty()) {
        attrString.addAttribute(TextAttribute.FONT, f);
        lines = tryTextLayout(attrString, frc, box, leftPadding, topPadding);
        f = f.deriveFont(f.getSize2D() - 0.5f);
    }
    return lines;
}
 
Example #13
Source File: NbToolTip.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static int getOffsetForPoint(Point p, JTextComponent c, BaseDocument doc) throws BadLocationException {
    if (p.x >= 0 && p.y >= 0) {
        int offset = c.viewToModel(p);
        Rectangle r = c.modelToView(offset);
        EditorUI eui = Utilities.getEditorUI(c);

        // Check that p is on a line with text and not completely below text,
        // ie. behind EOF.
        int relY = p.y - r.y;
        if (eui != null && relY < eui.getLineHeight()) {
            // Check that p is on a line with text before its EOL.
            if (offset < Utilities.getRowEnd(doc, offset)) {
                return offset;
            }
        }
    }
    
    return -1;
}
 
Example #14
Source File: MotifBorders.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/** Draws the FrameBorder's left border.
  */
protected boolean drawLeftBorder(Component c, Graphics g, int x, int y,
                       int width, int height) {
    Rectangle borderRect =
        new Rectangle(0, 0, getBorderInsets(c).left, height);
    if (!g.getClipBounds().intersects(borderRect)) {
        return false;
    }

    int startY = BORDER_SIZE;

    g.setColor(frameHighlight);
    g.drawLine(x, startY, x, height - 1);
    g.drawLine(x + 1, startY, x + 1, height - 2);

    g.setColor(frameColor);
    g.fillRect(x + 2, startY, x + 2, height - 3);

    g.setColor(frameShadow);
    g.drawLine(x + 4, startY, x + 4, height - 5);

    return true;
}
 
Example #15
Source File: BlockWidget.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void paintWidget() {
    super.paintWidget();
    Graphics2D g = this.getGraphics();
    Stroke old = g.getStroke();
    g.setColor(Color.BLUE);
    Rectangle r = new Rectangle(this.getPreferredBounds());
    r.width--;
    r.height--;
    if (this.getBounds().width > 0 && this.getBounds().height > 0) {
        g.setStroke(new BasicStroke(2));
        g.drawRect(r.x, r.y, r.width, r.height);
    }

    Color titleColor = Color.BLACK;
    g.setColor(titleColor);
    g.setFont(titleFont);

    String s = "B" + blockNode.toString();
    Rectangle2D r1 = g.getFontMetrics().getStringBounds(s, g);
    g.drawString(s, r.x + 5, r.y + (int) r1.getHeight());
    g.setStroke(old);
}
 
Example #16
Source File: CaretItem.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Repaint caret bounds if the caret is showing or do nothing
 * @param c
 * @return 
 */
synchronized Rectangle repaintIfShowing(JTextComponent c, String logMessage, int logIndex) {
    Rectangle bounds = this.caretBounds;
    if (bounds != null) {
        boolean repaint = (this.statusBits & CARET_PAINTED) != 0;
        if (repaint) {
            this.statusBits &= ~CARET_PAINTED;
            if (EditorCaret.LOG.isLoggable(Level.FINE)) {
                logRepaint(logMessage + "-repaintIfShowing", logIndex, bounds);
            }
            c.repaint(bounds);
        }
    }
    return bounds;
}
 
Example #17
Source File: RemoteFXScreenshot.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private static Rectangle convertBounds(ObjectReference bounds) {
    ClassType boundsClass = (ClassType)bounds.referenceType();
    Field minX = boundsClass.fieldByName("minX");
    Field minY = boundsClass.fieldByName("minY");
    Field width = boundsClass.fieldByName("width");
    Field height = boundsClass.fieldByName("height");

    return new Rectangle(((DoubleValue)bounds.getValue(minX)).intValue(), 
       ((DoubleValue)bounds.getValue(minY)).intValue(), 
       ((DoubleValue)bounds.getValue(width)).intValue(), 
       ((DoubleValue)bounds.getValue(height)).intValue()
    );
}
 
Example #18
Source File: RotatedPanel.java    From pumpernickel with MIT License 5 votes vote down vote up
@Override
public void layoutContainer(Container parent) {
	Component child = parent.getComponent(0);
	Dimension d = new Dimension(parent.getWidth(), parent.getHeight());
	d = getRotation().transform(d);
	child.setBounds(new Rectangle(0, 0, d.width, d.height));
}
 
Example #19
Source File: VariableHeightLayoutCache.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Retursn the bounds for row, <code>row</code> by reference in
 * <code>placeIn</code>. If <code>placeIn</code> is null a new
 * Rectangle will be created and returned.
 */
private Rectangle getBounds(int row, Rectangle placeIn) {
    if(updateNodeSizes)
        updateNodeSizes(false);

    if(row >= 0 && row < getRowCount()) {
        return getNode(row).getNodeBounds(placeIn);
    }
    return null;
}
 
Example #20
Source File: Raster.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a Raster with the given SampleModel, DataBuffer, and
 * parent.  aRegion specifies the bounding rectangle of the new
 * Raster.  When translated into the base Raster's coordinate
 * system, aRegion must be contained by the base Raster.
 * (The base Raster is the Raster's ancestor which has no parent.)
 * sampleModelTranslate specifies the sampleModelTranslateX and
 * sampleModelTranslateY values of the new Raster.
 *
 * Note that this constructor should generally be called by other
 * constructors or create methods, it should not be used directly.
 * @param sampleModel     The SampleModel that specifies the layout
 * @param dataBuffer      The DataBuffer that contains the image data
 * @param aRegion         The Rectangle that specifies the image area
 * @param sampleModelTranslate  The Point that specifies the translation
 *                        from SampleModel to Raster coordinates
 * @param parent          The parent (if any) of this raster
 * @throws NullPointerException if any of <code>sampleModel</code>,
 *         <code>dataBuffer</code>, <code>aRegion</code> or
 *         <code>sampleModelTranslate</code> is null
 * @throws RasterFormatException if <code>aRegion</code> has width
 *         or height less than or equal to zero, or computing either
 *         <code>aRegion.x + aRegion.width</code> or
 *         <code>aRegion.y + aRegion.height</code> results in integer
 *         overflow
 */
protected Raster(SampleModel sampleModel,
                 DataBuffer dataBuffer,
                 Rectangle aRegion,
                 Point sampleModelTranslate,
                 Raster parent) {

    if ((sampleModel == null) || (dataBuffer == null) ||
        (aRegion == null) || (sampleModelTranslate == null)) {
        throw new NullPointerException("SampleModel, dataBuffer, aRegion and " +
                                       "sampleModelTranslate cannot be null");
    }
   this.sampleModel = sampleModel;
   this.dataBuffer = dataBuffer;
   minX = aRegion.x;
   minY = aRegion.y;
   width = aRegion.width;
   height = aRegion.height;
   if (width <= 0 || height <= 0) {
       throw new RasterFormatException("negative or zero " +
           ((width <= 0) ? "width" : "height"));
   }
   if ((minX + width) < minX) {
       throw new RasterFormatException(
           "overflow condition for X coordinates of Raster");
   }
   if ((minY + height) < minY) {
       throw new RasterFormatException(
           "overflow condition for Y coordinates of Raster");
   }

   sampleModelTranslateX = sampleModelTranslate.x;
   sampleModelTranslateY = sampleModelTranslate.y;

   numBands = sampleModel.getNumBands();
   numDataElements = sampleModel.getNumDataElements();
   this.parent = parent;
}
 
Example #21
Source File: Dock.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void paintChildren(Graphics gc) {
    super.paintChildren(gc);
    if (mDragOverNode != null) {
        Rectangle bounds = getDragOverBounds();
        gc.setColor(DockColors.DROP_AREA);
        gc.fillRect(bounds.x, bounds.y, bounds.width, bounds.height);
        gc.setColor(DockColors.DROP_AREA_INNER_BORDER);
        gc.drawRect(bounds.x + 1, bounds.y + 1, bounds.width - 3, bounds.height - 3);
        gc.setColor(DockColors.DROP_AREA_OUTER_BORDER);
        gc.drawRect(bounds.x, bounds.y, bounds.width - 1, bounds.height - 1);
    }
}
 
Example #22
Source File: Geometry.java    From gcs with Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Unions two {@link Rectangle}s, producing a third. Unlike the {@link
 * Rectangle#union(Rectangle)} method, an empty {@link Rectangle} will not cause the {@link
 * Rectangle}'s boundary to extend to the 0,0 point.
 *
 * @param first  The first {@link Rectangle}.
 * @param second The second {@link Rectangle}.
 * @return The resulting {@link Rectangle}.
 */
public static Rectangle union(Rectangle first, Rectangle second) {
    boolean firstEmpty  = first.width < 1 || first.height < 1;
    boolean secondEmpty = second.width < 1 || second.height < 1;
    if (firstEmpty && secondEmpty) {
        return new Rectangle();
    }
    if (firstEmpty) {
        return new Rectangle(second);
    }
    if (secondEmpty) {
        return new Rectangle(first);
    }
    return first.union(second);
}
 
Example #23
Source File: NavlinkUI.java    From RipplePower with Apache License 2.0 5 votes vote down vote up
protected void paintText(Graphics g, JComponent c, Rectangle textRect, String text) {
	AbstractButton b = (AbstractButton) c;
	ButtonModel model = b.getModel();
	FontMetrics fm = g.getFontMetrics();
	int mnemIndex = b.getDisplayedMnemonicIndex();

	if (model.isEnabled()) {
		g.setColor(b.getForeground());
	} else {
		g.setColor(getDisabledTextColor());
	}
	BasicGraphicsUtils.drawStringUnderlineCharAt(g, text, mnemIndex, textRect.x, textRect.y + fm.getAscent());
}
 
Example #24
Source File: SynthToolBarUI.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Paints the toolbar content.
 *
 * @param context context for the component being painted
 * @param g {@code Graphics} object used for painting
 * @param bounds bounding box for the toolbar
 */
protected void paintContent(SynthContext context, Graphics g,
        Rectangle bounds) {
    SynthLookAndFeel.updateSubregion(context, g, bounds);
    context.getPainter().paintToolBarContentBackground(context, g,
                         bounds.x, bounds.y, bounds.width, bounds.height,
                         toolBar.getOrientation());
    context.getPainter().paintToolBarContentBorder(context, g,
                         bounds.x, bounds.y, bounds.width, bounds.height,
                         toolBar.getOrientation());
}
 
Example #25
Source File: DesktopImpl.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void performSlideIntoEdge(SlideOperation operation, Rectangle editorBounds) {
    operation.setFinishBounds(computeLastButtonBounds(operation));
    Rectangle screenStart = operation.getStartBounds();
    operation.setStartBounds(convertRectFromScreen(layeredPane, screenStart));
    
    performSlide(operation);
}
 
Example #26
Source File: ByteComponentRaster.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Constructs a ByteComponentRaster with the given SampleModel.
 * The Raster's upper left corner is origin and it is the same
 * size as the SampleModel.  A DataBuffer large enough to describe the
 * Raster is automatically created.  SampleModel must be of type
 * SinglePixelPackedSampleModel or ComponentSampleModel.
 * @param sampleModel     The SampleModel that specifies the layout.
 * @param origin          The Point that specified the origin.
 */
public ByteComponentRaster(SampleModel sampleModel, Point origin) {
    this(sampleModel,
         sampleModel.createDataBuffer(),
         new Rectangle(origin.x,
                       origin.y,
                       sampleModel.getWidth(),
                       sampleModel.getHeight()),
         origin,
         null);
}
 
Example #27
Source File: XWM.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void setShellNotResizable(XDecoratedPeer window, WindowDimensions newDimensions, Rectangle shellBounds,
                                 boolean justChangeSize)
{
    if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
        insLog.fine("Setting non-resizable shell " + window + ", dimensions " + newDimensions +
                    ", shellBounds " + shellBounds +", just change size: " + justChangeSize);
    }
    XToolkit.awtLock();
    try {
        /* Fix min/max size hints at the specified values */
        if (!shellBounds.isEmpty()) {
            window.updateSizeHints(newDimensions);
            requestWMExtents(window.getWindow());
            XToolkit.XSync();
            XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(),
                                          window.getShell(),
                                          window.scaleUp(shellBounds.x),
                                          window.scaleUp(shellBounds.y),
                                          window.scaleUp(shellBounds.width),
                                          window.scaleUp(shellBounds.height));
        }
        if (!justChangeSize) {  /* update decorations */
            setShellDecor(window);
        }
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example #28
Source File: ByteComponentRaster.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Creates a Writable subRaster given a region of the Raster. The x and y
 * coordinates specify the horizontal and vertical offsets
 * from the upper-left corner of this Raster to the upper-left corner
 * of the subRaster.  A subset of the bands of the parent Raster may
 * be specified.  If this is null, then all the bands are present in the
 * subRaster. A translation to the subRaster may also be specified.
 * Note that the subRaster will reference the same
 * DataBuffer as the parent Raster, but using different offsets.
 * @param x               X offset.
 * @param y               Y offset.
 * @param width           Width (in pixels) of the subraster.
 * @param height          Height (in pixels) of the subraster.
 * @param x0              Translated X origin of the subraster.
 * @param y0              Translated Y origin of the subraster.
 * @param bandList        Array of band indices.
 * @exception RasterFormatException
 *            if the specified bounding box is outside of the parent Raster.
 */
public WritableRaster createWritableChild(int x, int y,
                                          int width, int height,
                                          int x0, int y0,
                                          int[] bandList) {
    if (x < this.minX) {
        throw new RasterFormatException("x lies outside the raster");
    }
    if (y < this.minY) {
        throw new RasterFormatException("y lies outside the raster");
    }
    if ((x+width < x) || (x+width > this.minX + this.width)) {
        throw new RasterFormatException("(x + width) is outside of Raster");
    }
    if ((y+height < y) || (y+height > this.minY + this.height)) {
        throw new RasterFormatException("(y + height) is outside of Raster");
    }

    SampleModel sm;

    if (bandList != null)
        sm = sampleModel.createSubsetSampleModel(bandList);
    else
        sm = sampleModel;

    int deltaX = x0 - x;
    int deltaY = y0 - y;

    return new ByteComponentRaster(sm,
                                   dataBuffer,
                                   new Rectangle(x0, y0, width, height),
                                   new Point(sampleModelTranslateX+deltaX,
                                             sampleModelTranslateY+deltaY),
                                   this);
}
 
Example #29
Source File: DisplayCanvas.java    From TrakEM2 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Repaint the given offscreen Rectangle after transforming its data on the fly to the
 * srcRect and magnification of this DisplayCanvas. The Rectangle is not
 * modified.
 */
public void repaint(final Rectangle r, final int extra) {
	invalidateVolatile();
	if (null == r) {
		//Utils.log2("DisplayCanvas.repaint(Rectangle, int) warning: null r");
		RT.paint(null, update_graphics);
		return;
	}
	// repaint((int) ((r.x - srcRect.x) * magnification) - extra, (int) ((r.y - srcRect.y) * magnification) - extra, (int) Math .ceil(r.width * magnification) + extra + extra, (int) Math.ceil(r.height * magnification) + extra + extra);
	RT.paint(new Rectangle((int) ((r.x - srcRect.x) * magnification) - extra, (int) ((r.y - srcRect.y) * magnification) - extra, (int) Math.ceil(r.width * magnification) + extra + extra, (int) Math.ceil(r.height * magnification) + extra + extra), update_graphics);
}
 
Example #30
Source File: RecipeHandlerBottler.java    From NEI-Integration with MIT License 5 votes vote down vote up
public CachedBottlerRecipe(MachineBottler.Recipe recipe) {
    if (recipe.input != null) {
        this.fluid = new PositionedFluidTank(recipe.input, 10000, new Rectangle(48, 6, 16, 58), RecipeHandlerBottler.this.getGuiTexture(), new Point(176, 0));
    }
    if (recipe.can != null) {
        this.input = new PositionedStack(recipe.can, 111, 8);
    }
    if (recipe.bottled != null) {
        this.output = new PositionedStack(recipe.bottled, 111, 44);
    }
}