Java Code Examples for java.awt.Rectangle

The following are top voted examples for showing how to use java.awt.Rectangle. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: TableView.java   View source code 6 votes vote down vote up
/** Synchronize the selected nodes from the manager of this Explorer.
 */
final void synchronizeSelectedNodes() {
    Node[] arr = manager.getSelectedNodes ();
    table.getSelectionModel().clearSelection();
    NodeTableModel ntm = (NodeTableModel)table.getModel();
    int size = ntm.getRowCount();
    int firstSelection = -1;
    for (int i = 0; i < size; i++) {
        Node n = getNodeFromRow(i);
        for (int j = 0; j < arr.length; j++) {
            if (n.equals(arr[j])) {
                table.getSelectionModel().addSelectionInterval(i, i);
                if (firstSelection == -1) {
                    firstSelection = i;
                }
            }
        }
    }
    if (firstSelection >= 0) {
        Rectangle rect = table.getCellRect(firstSelection, 0, true);
        if (!getViewport().getViewRect().contains(rect.getLocation())) {
            rect.height = Math.max(rect.height, getHeight() - 30);
            table.scrollRectToVisible(rect);
        }
    }
}
 
Example 2
Project: rapidminer   File: SliderUI.java   View source code 6 votes vote down vote up
@Override
public void paint(Graphics g, JComponent c) {
	recalculateIfInsetsChanged();
	recalculateIfOrientationChanged();
	Rectangle clip = g.getClipBounds();

	if (!clip.intersects(trackRect) && slider.getPaintTrack()) {
		calculateGeometry();
	}

	if (slider.getPaintTrack() && clip.intersects(trackRect)) {
		paintTrack(g);
	}
	if (slider.hasFocus() && clip.intersects(focusRect)) {
		paintFocus(g);
	}

	// the ticks are now inside the track so they have to be painted each thumb movement
	paintTicks(g);
	// thumb is always painted due to value below thumb
	paintThumb(g);
}
 
Example 3
Project: powertext   File: RSyntaxTextArea.java   View source code 6 votes vote down vote up
private void updateAndInvalidate(Rectangle r) {
	if (pulseCount<5) {
		r.x--;
		r.y--;
		r.width += 2;
		r.height += 2;
		repaint(r.x,r.y, r.width,r.height);
	}
	else if (pulseCount<7) {
		r.x++;
		r.y++;
		r.width -= 2;
		r.height -= 2;
		repaint(r.x-2,r.y-2, r.width+5,r.height+5);
	}
}
 
Example 4
Project: brModelo   File: Forma.java   View source code 6 votes vote down vote up
@Override
public void reSetBounds() {
    PontoElementar[] pontos = getPontos();
    int espacoI = distSelecao;
    int mW = pontos[0].getWidth() + espacoI;
    int mH = pontos[0].getHeight() + espacoI;

    int H = pontos[2].getTop() - pontos[0].getTop() - (mH + espacoI);
    int W = pontos[2].getLeft() - pontos[0].getLeft() - (mW + espacoI);
    int L = pontos[0].getLeft() + mW;
    int T = pontos[0].getTop() + mH;

    if ((W < 10) || (H < 10)) {
        Reposicione();
        return;
    }

    Rectangle ret = new Rectangle(getLeft() - L, getTop() - T, getWidth() - W, getHeight() - H);
    DoFormaResize(ret);
}
 
Example 5
Project: ramus   File: GEFComponent.java   View source code 6 votes vote down vote up
private Bounds[] getBoundsInRectangle(Rectangle rectangle) {
    List<Bounds> list = new ArrayList<Bounds>();
    double maxX = untranslate(rectangle.getMaxX());
    double minX = untranslate(rectangle.getMinX());
    double maxY = untranslate(rectangle.getMaxY());
    double minY = untranslate(rectangle.getMinY());

    for (Bounds bounds : diagram.getBounds()) {
        if ((bounds.getLeft() <= maxX) && (bounds.getLeft() >= minX)
                && (bounds.getRight() <= maxX)
                && (bounds.getRight() >= minX)) {
            if ((bounds.getTop() <= maxY) && (bounds.getTop() >= minY)
                    && (bounds.getBottom() <= maxY)
                    && (bounds.getBottom() >= minY)) {
                list.add(bounds);
            }
        }
    }

    return list.toArray(new Bounds[list.size()]);
}
 
Example 6
Project: openjdk-jdk10   File: DrawTest.java   View source code 6 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    e.consume();
    switch (mode) {
        case LINES:
            x1 = e.getX();
            y1 = e.getY();
            x2 = -1;
            break;
        case POINTS:
        default:
            colors.add(getForeground());
            lines.add(new Rectangle(e.getX(), e.getY(), -1, -1));
            x1 = e.getX();
            y1 = e.getY();
            repaint();
            break;
    }
}
 
Example 7
Project: incubator-netbeans   File: ParagraphViewChildren.java   View source code 6 votes vote down vote up
void paintChildren(ParagraphView pView, Graphics2D g, Shape pAlloc, Rectangle clipBounds,
        int startIndex, int endIndex)
{
    while (startIndex < endIndex) {
        EditorView view = get(startIndex);
        Shape childAlloc = getChildAllocation(startIndex, pAlloc);
        if (view.getClass() == NewlineView.class) {
            // Extend till end of screen (docView's width)
            Rectangle2D.Double childRect = ViewUtils.shape2Bounds(childAlloc);
            DocumentView docView = pView.getDocumentView();
            // Note that op.getVisibleRect() may be obsolete - it does not incorporate
            // possible just performed horizontal scroll while clipBounds already does.
            double maxX = Math.max(
                    Math.max(docView.op.getVisibleRect().getMaxX(), clipBounds.getMaxX()),
                    childRect.getMaxX()
            );
            childRect.width = (maxX - childRect.x);
            childAlloc = childRect;
        }
        view.paint(g, childAlloc, clipBounds);
        startIndex++;
    }
}
 
Example 8
Project: geomapapp   File: MapServerA.java   View source code 6 votes vote down vote up
public static double[] fitWESN(double[] wesn, int width, int height) {
	Rectangle rect = new Rectangle(0, 0, width, height);
	double scale = (wesn[1] - wesn[0]) / (double)width;
	double scaleY = (wesn[3] - wesn[2]) / (double)height;
	double x0, y0;
	if(scaleY > scale) {
		scale = scaleY;
		x0 = .5d * (wesn[0] + wesn[1]);
		wesn[0] = x0 - (double)width * .5d * scale;
		wesn[1] = wesn[0] + (double)width * scale;
	} else {
		y0 = .5d * (wesn[2] + wesn[3]);
		wesn[3] = y0 + (double)height * .5d * scale;
		wesn[2] = wesn[3] - (double)height * scale;
	}
	return wesn;
}
 
Example 9
Project: Equella   File: LabelSeparator.java   View source code 6 votes vote down vote up
public LabelSeparator(JLabel label)
{
	JSeparator separator = new JSeparator();

	final int height1 = label.getPreferredSize().height;
	final int height2 = separator.getPreferredSize().height;
	final int height3 = (height1 - height2) / 2;
	final int width1 = label.getPreferredSize().width;

	final int[] rows = {height3, height2, height3,};
	final int[] cols = {width1, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));

	add(label, new Rectangle(0, 0, 1, 3));
	add(separator, new Rectangle(1, 1, 1, 1));
}
 
Example 10
Project: openjdk-jdk10   File: RobotMultiDPIScreenTest.java   View source code 6 votes vote down vote up
static void initScreenBounds() {

        GraphicsDevice[] devices = GraphicsEnvironment
                .getLocalGraphicsEnvironment()
                .getScreenDevices();

        screenBounds = new Rectangle[devices.length];
        scales = new double[devices.length][2];
        for (int i = 0; i < devices.length; i++) {
            GraphicsConfiguration gc = devices[i].getDefaultConfiguration();
            screenBounds[i] = gc.getBounds();
            AffineTransform tx = gc.getDefaultTransform();
            scales[i][0] = tx.getScaleX();
            scales[i][1] = tx.getScaleY();
        }

        maxBounds = screenBounds[0];
        for (int i = 0; i < screenBounds.length; i++) {
            maxBounds = maxBounds.union(screenBounds[i]);
        }
    }
 
Example 11
Project: jdk8u-jdk   File: RepaintArea.java   View source code 6 votes vote down vote up
/**
 * Adds a <code>Rectangle</code> to this <code>RepaintArea</code>.
 * PAINT Rectangles are divided into mostly vertical and mostly horizontal.
 * Each group is unioned together.
 * UPDATE Rectangles are unioned.
 *
 * @param   r   the specified <code>Rectangle</code>
 * @param   id  possible values PaintEvent.UPDATE or PaintEvent.PAINT
 * @since   1.3
 */
public synchronized void add(Rectangle r, int id) {
    // Make sure this new rectangle has positive dimensions
    if (r.isEmpty()) {
        return;
    }
    int addTo = UPDATE;
    if (id == PaintEvent.PAINT) {
        addTo = (r.width > r.height) ? HORIZONTAL : VERTICAL;
    }
    if (paintRects[addTo] != null) {
        paintRects[addTo].add(r);
    } else {
        paintRects[addTo] = new Rectangle(r);
    }
}
 
Example 12
Project: OpenJSharp   File: AquaTabbedPaneContrastUI.java   View source code 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 13
Project: OpenJSharp   File: DrawTest.java   View source code 6 votes vote down vote up
@Override
public void mousePressed(MouseEvent e) {
    e.consume();
    switch (mode) {
        case LINES:
            x1 = e.getX();
            y1 = e.getY();
            x2 = -1;
            break;
        case POINTS:
        default:
            colors.add(getForeground());
            lines.add(new Rectangle(e.getX(), e.getY(), -1, -1));
            x1 = e.getX();
            y1 = e.getY();
            repaint();
            break;
    }
}
 
Example 14
Project: openjdk-jdk10   File: SynthTreeUI.java   View source code 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintExpandControl(Graphics g, Rectangle clipBounds,
        Insets insets, Rectangle bounds, TreePath path, int row,
        boolean isExpanded, boolean hasBeenExpanded, boolean isLeaf) {
    //modify the paintContext's state to match the state for the row
    //this is a hack in that it requires knowledge of the subsequent
    //method calls. The point is, the context used in drawCentered
    //should reflect the state of the row, not of the tree.
    boolean isSelected = tree.getSelectionModel().isPathSelected(path);
    int state = paintContext.getComponentState();
    if (isSelected) {
        paintContext.setComponentState(state | SynthConstants.SELECTED);
    }
    super.paintExpandControl(g, clipBounds, insets, bounds, path, row,
            isExpanded, hasBeenExpanded, isLeaf);
    paintContext.setComponentState(state);
}
 
Example 15
Project: opentest   File: ImageFinder.java   View source code 6 votes vote down vote up
@Override
public ImageFinderResult findImage(Rectangle sourceScreenRect, BufferedImage templateImage, double desiredAccuracy) {
    try {
        BufferedImage capture = new Robot().createScreenCapture(sourceScreenRect);
        Mat sourceMat = CvHelper.convertToMat(capture);
        Mat templateMat = CvHelper.convertToMat(templateImage);
        return this.findImage(sourceMat, templateMat, desiredAccuracy);
    } catch (Exception ex) {
        throw new RuntimeException(String.format(
                "An error ocurred while trying to find an image on screen at (%s, %s, %s, %s)",
                sourceScreenRect.x,
                sourceScreenRect.y,
                sourceScreenRect.width,
                sourceScreenRect.height), ex);
    }
}
 
Example 16
Project: VASSAL-src   File: PositionOption.java   View source code 6 votes vote down vote up
public void setValue(String in) {
  final StringTokenizer st = new StringTokenizer(in, ",");
  try {
    setValue(new Rectangle(Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken()),
                           Integer.parseInt(st.nextToken())));
  }
  catch (NumberFormatException e) {
    // This can happen if a VisibilityOption has the same name
    // as a PositionOption, either currently, or due to editing.
    // Don't throw a bug, just log it.
    if (in.indexOf('\t') > 0) {
      ErrorDialog.dataError(new BadDataReport("Map or Chart window with same name as piece Palette", getKey(), e));
    }
    else {
      ErrorDialog.bug(e);
    }
  }
}
 
Example 17
Project: MTG-Card-Recognizer   File: ScreenRegionGrab.java   View source code 6 votes vote down vote up
@Override
public void mouseClicked(MouseEvent arg0) {
	Point p = MouseInfo.getPointerInfo().getLocation();
	if(num==1)
	{
		pt1 = p;
		win2 = new ScreenRegionGrab(2);
	}
	else
	{
		pt2 = p;
		int x = Math.min(pt1.x,pt2.x);
		int y = Math.min(pt1.y, pt2.y);
		int w = Math.max(pt1.x,pt2.x)-x;
		int h = Math.max(pt1.y,pt2.y)-y;
		BufferedImage a = rob.createScreenCapture(new Rectangle(x,y,w,h));
		RecogApp.doRecog(a);
		win1.dispose();
		win1=win2=null;
		pt1=pt2=null;
		dispose();
	}
}
 
Example 18
Project: Pixie   File: BoundingBoxWindow.java   View source code 5 votes vote down vote up
/**
 * Restore the object to the original position. The user made changes but
 * does not want to keep them.
 */
private void restoreObjOrigPos() {
    // reset the object coordinates
    currentObject.setOuterBBox(new Rectangle(origObjPos));

    // refresh the displayed image
    displayImage();

    // change the title of the frame
    setFrameTitle();

    // refresh also the image on the gui
    observable.notifyObservers(ObservedActions.Action.SELECTED_OBJECT_MOVED);
}
 
Example 19
Project: VASSAL-src   File: ImageUtils.java   View source code 5 votes vote down vote up
public static Rectangle transform(Rectangle srect,
                                  double scale,
                                  double angle) {
  final AffineTransform t = AffineTransform.getRotateInstance(
    DEGTORAD*angle, srect.getCenterX(), srect.getCenterY());
  t.scale(scale, scale);
  return t.createTransformedShape(srect).getBounds();
}
 
Example 20
Project: geomapapp   File: Zoom.java   View source code 5 votes vote down vote up
public void mouseDragged(MouseEvent e) {
		if( !zoomIn.isSelected() && !zoomOut.isSelected() )return;
		Rectangle shape = new Rectangle( start.x, start.y, 0, 0);
		shape.add(e.getPoint());
	//	if( shape.width<=10 || shape.height<=10 )return;
//System.out.println( shape.width +"\t"+ shape.height );
		sc.setShape( shape);
	}
 
Example 21
Project: sumo   File: MultiThumbSlider.java   View source code 5 votes vote down vote up
public void installUI(JComponent c) {
    mSlider = (MThumbSlider) c;
    thumbNum = mSlider.getThumbNum();
    thumbRects = new Rectangle[thumbNum];
    for (int i = 0; i < thumbNum; i++) {
        thumbRects[i] = new Rectangle();
    }
    isDragging = false;
    trackListener = new MThumbSliderAdditionalUI.TrackListener(mSlider);
    changeHandler = new ChangeHandler();
}
 
Example 22
Project: GitHub   File: RectangleDeserializerTest.java   View source code 5 votes vote down vote up
public void test_stack_error_0() throws Exception {
    Exception error = null;
    try {
        JSON.parseObject("[]", Rectangle.class);
    } catch (JSONException ex) {
        error = ex;
    }
    Assert.assertNotNull(error);
}
 
Example 23
Project: incubator-netbeans   File: JXTableDecorator.java   View source code 5 votes vote down vote up
/**
 * Paints the backgrounds of the implied empty rows when the
 * table model is insufficient to fill all the visible area
 * available to us. We don't involve cell renderers, because
 * we have no data.
 */
protected void paintEmptyRows(Graphics g) {
    final int rowCount = getRowCount();
    final Rectangle clip = g.getClipBounds();
    final int height = clip.y + clip.height;
    if (rowCount * rowHeight < height) {
        for (int i = rowCount; i <= height / rowHeight; ++i) {
            g.setColor(backgroundColorForRow(i));
            g.fillRect(clip.x, i * rowHeight, clip.width, rowHeight);
            drawHorizontalLine(g, clip, i);
        }
        drawVerticalLines(g, rowCount, height);
    }
}
 
Example 24
Project: geomapapp   File: PersTool.java   View source code 5 votes vote down vote up
boolean update() {
	Dimension d = pImage.getSize();
	Insets ins = pImage.getInsets();
	d.width -= ins.left+ins.right;
	d.height -= ins.top+ins.bottom;
	Rectangle r = new Rectangle( -d.width/2, -d.height/2,
				d.width, d.height);
	
	return pImage.run( getPerspective(), r,
			grid.getGrid(), grid.getImage(), veTool.getVE());
}
 
Example 25
Project: incubator-netbeans   File: TabTable.java   View source code 5 votes vote down vote up
Rectangle getTabBounds( int tabIndex ) {
    TabTableModel tabModel = ( TabTableModel ) getModel();
    int col = tabModel.toColumnIndex( tabIndex );
    int row = tabModel.toRowIndex( tabIndex );
    if( row >= 0 && col >= 0 ) {
        col = convertColumnIndexToView( col );
        row = convertRowIndexToView( row );
        return getCellRect( row, col, true );
    }
    return null;
}
 
Example 26
Project: VTerminal   File: Screen.java   View source code 5 votes vote down vote up
/**
 * Adds a component to the screen and registers event listeners of the
 * component, to the parent panel, if required.
 *
 * If the component is already present on the screen, then the component is
 * not added.
 *
 * If the component is a screen and it has already been added to this screen,
 * or any sub-screen of this screen, then the component is not added.
 *
 * @param component
 *          The component.
 */
public void addComponent(final Component component) {
    componentsLock.writeLock().lock();

    boolean containsComponent = containsComponent(component);

    if (containsComponent) {
        componentsLock.writeLock().unlock();
        return;
    }

    // Add the component to one of the component lists:
    component.getRadio().addReceiver("DRAW", this);

    if (component instanceof Screen) {
        ((Screen) component).setParentPanel(parentPanel);
        screenComponents.add((Screen) component);
    } else if (component instanceof Layer) {
        layerComponents.add((Layer) component);
    } else {
        components.add(component);
    }

    // Add screen position as offset to bounding box position of component.
    final Rectangle boundingBox = component.getBoundingBox();
    final int x = boundingBox.x + super.getPosition().x;
    final int y = boundingBox.y + super.getPosition().y;
    component.getBoundingBox().setLocation(x, y);

    componentsLock.writeLock().unlock();

    // Set up event listeners:
    component.createEventListeners(parentPanel);

    for (final EventListener eventListener : component.getEventListeners()) {
        parentPanel.addListener(eventListener);
    }
}
 
Example 27
Project: incubator-netbeans   File: Central.java   View source code 5 votes vote down vote up
@Override
public void userResizedEditorAreaBoundsHelp(Rectangle bounds) {
    if(getEditorAreaState() == Constants.EDITOR_AREA_JOINED
    && getEditorAreaBounds().isEmpty()) {
        model.setEditorAreaBoundsUserHelp(bounds);
    }
}
 
Example 28
Project: Progetto-C   File: SheetPanel.java   View source code 5 votes vote down vote up
/**
 * Create a panel showing a sprite sheet
 * 
 * @param p The GUI tool this panel is part of
 */
public SheetPanel(Packer p) {
	this.packer = p;
	
	Color base = Color.gray;
	BufferedImage image = new BufferedImage(50, 50,
			BufferedImage.TYPE_INT_ARGB);
	Graphics2D g = (Graphics2D) image.getGraphics();
	g.setColor(base);
	g.fillRect(0, 0, image.getWidth(), image.getHeight());
	g.setColor(base.darker());
	g.fillRect(image.getWidth() / 2, 0, image.getWidth() / 2, image
			.getHeight() / 2);
	g.fillRect(0, image.getHeight() / 2, image.getWidth() / 2, image
			.getHeight() / 2);

	background = new TexturePaint(image, new Rectangle(0, 0, image
			.getWidth(), image.getHeight()));
	
	addMouseListener(new MouseAdapter() {
		public void mousePressed(MouseEvent e) {
			Sprite sprite = packer.getSpriteAt(e.getX(), e.getY());
			
			if (sprite != null) {
				ArrayList selection = new ArrayList();
				if ((e.getModifiersEx() & MouseEvent.SHIFT_DOWN_MASK) != 0) {
					selection.addAll(selected);
				}
				selection.add(sprite);
				
				packer.select(selection);
			}
		}
	});
}
 
Example 29
Project: Equella   File: StepDialog.java   View source code 5 votes vote down vote up
private void setup()
{
	JLabel label = new JLabel(CurrentLocale.get("com.tle.admin.workflow.stepdialog.title"));

	model = new GenericListModel<Class<? extends WorkflowNode>>();
	list = new JList(model);
	list.setCellRenderer(new WorkflowCellRenderer());
	list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	list.addListSelectionListener(this);
	list.addMouseListener(this);

	ok = new JButton(CurrentLocale.get("com.tle.admin.ok"));
	cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel"));

	ok.addActionListener(this);
	cancel.addActionListener(this);

	final int height1 = label.getPreferredSize().height;
	final int height2 = ok.getPreferredSize().height;
	final int width1 = cancel.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL, height2,};
	final int[] cols = {TableLayout.FILL, width1, width1,};

	content = new JPanel(new TableLayout(rows, cols));
	content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

	content.add(label, new Rectangle(0, 0, 3, 1));
	content.add(new JScrollPane(list), new Rectangle(0, 1, 3, 1));
	content.add(ok, new Rectangle(1, 2, 1, 1));
	content.add(cancel, new Rectangle(2, 2, 1, 1));

	updateButtons();
}
 
Example 30
Project: incubator-netbeans   File: WinClassicViewTabDisplayerUI.java   View source code 5 votes vote down vote up
/**
 * Paints lower border, bottom line, separating tabs from content
 */
protected void paintOverallBorder(Graphics g, JComponent c) {
    if (isGenericUI) {
        return;
    }
    Rectangle r = c.getBounds();
    g.setColor(UIManager.getColor("InternalFrame.borderDarkShadow")); //NOI18N
    g.drawLine(0, r.height - 1, r.width - 1, r.height - 1);
}
 
Example 31
Project: openjdk-jdk10   File: XWM.java   View source code 5 votes vote down vote up
static void setShellResizable(XDecoratedPeer window) {
    if (insLog.isLoggable(PlatformLogger.Level.FINE)) {
        insLog.fine("Setting shell resizable " + window);
    }
    XToolkit.awtLock();
    try {
        Rectangle shellBounds;
        if (getWMID() != UNITY_COMPIZ_WM) {
            shellBounds = window.getShellBounds();
            shellBounds.translate(-window.currentInsets.left,
                                  -window.currentInsets.top);
        } else {
            shellBounds = window.getDimensions().getScreenBounds();
        }
        window.updateSizeHints(window.getDimensions());
        requestWMExtents(window.getWindow());
        XlibWrapper.XMoveResizeWindow(XToolkit.getDisplay(),
                                      window.getShell(),
                                      window.scaleUp(shellBounds.x),
                                      window.scaleUp(shellBounds.y),
                                      window.scaleUp(shellBounds.width),
                                      window.scaleUp(shellBounds.height));
        /* REMINDER: will need to revisit when setExtendedStateBounds is added */
        //Fix for 4320050: Minimum size for java.awt.Frame is not being enforced.
        //We need to update frame's minimum size, not to reset it
        removeSizeHints(window, XUtilConstants.PMaxSize);
        window.updateMinimumSize();

        /* Restore decorations */
        setShellDecor(window);
    } finally {
        XToolkit.awtUnlock();
    }
}
 
Example 32
Project: jdk8u-jdk   File: VariableHeightLayoutCache.java   View source code 5 votes vote down vote up
/**
  * Returns the <code>Rectangle</code> enclosing the label portion
  * into which the item identified by <code>path</code> will be drawn.
  *
  * @param path  the path to be drawn
  * @param placeIn the bounds of the enclosing rectangle
  * @return the bounds of the enclosing rectangle or <code>null</code>
  *    if the node could not be ascertained
  */
public Rectangle getBounds(TreePath path, Rectangle placeIn) {
    TreeStateNode       node = getNodeForPath(path, true, false);

    if(node != null) {
        if(updateNodeSizes)
            updateNodeSizes(false);
        return node.getNodeBounds(placeIn);
    }
    return null;
}
 
Example 33
Project: openjdk-jdk10   File: JTreeOperator.java   View source code 5 votes vote down vote up
/**
 * Retuns points which can be used to click on path.
 *
 * @param row a row index to click on.
 * @return a Point in component's coordinate system.
 */
public Point getPointToClick(int row) {
    Rectangle rect = getRowBounds(row);
    if (rect != null) {
        return (new Point((int) (rect.getX() + rect.getWidth() / 2),
                (int) (rect.getY() + rect.getHeight() / 2)));
    } else {
        throw (new NoSuchPathException(row));
    }
}
 
Example 34
Project: ramus   File: DataLoader.java   View source code 5 votes vote down vote up
public static Rectangle readRectangle(final InputStream stream)
        throws IOException {
    final double x = readDouble(stream);
    final double y = readDouble(stream);
    final double w = readDouble(stream);
    final double h = readDouble(stream);
    final Rectangle rec = new Rectangle();
    rec.setFrame(x, y, w, h);
    return rec;
}
 
Example 35
Project: incubator-netbeans   File: ProfilerXYTooltipOverlay.java   View source code 5 votes vote down vote up
private void setPosition(List<ItemSelection> selectedItems, PaintersModel paintersModel, ChartContext chartContext) {
    int tooltipX = -1;
    int tooltipY = mousePosition.y;
    for (ItemSelection selection : selectedItems) {
        ChartItem item = selection.getItem();
        ItemPainter painter = paintersModel.getPainter(item);
        Rectangle bounds = Utils.checkedRectangle(
                           painter.getSelectionBounds(selection,
                           chartContext));
        if (tooltipX == -1) tooltipX += bounds.x + bounds.width / 2;
    }

    setPosition(normalizePosition(new Point(tooltipX, tooltipY)));
}
 
Example 36
Project: AeroStory   File: MapleMist.java   View source code 5 votes vote down vote up
public MapleMist(Rectangle mistPosition, MapleMonster mob, MobSkill skill) {
    this.mistPosition = mistPosition;
    this.mob = mob;
    this.skill = skill;
    isMobMist = true;
    isPoisonMist = true;
    skillDelay = 0;
}
 
Example 37
Project: OpenJSharp   File: ByteBandedRaster.java   View source code 5 votes vote down vote up
/**
 *  Constructs a ByteBandedRaster with the given sampleModel,
 *  DataBuffer, and parent. DataBuffer must be a DataBufferShort and
 *  SampleModel must be of type BandedSampleModel.
 *  When translated into the base Raster's
 *  coordinate system, aRegion must be contained by the base Raster.
 *  Origin is the coordinate in the new Raster's coordinate system of
 *  the origin of the base Raster.  (The base Raster is the Raster's
 *  ancestor which has no parent.)
 *
 *  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 DataBufferShort that contains the image data.
 *  @param aRegion         The Rectangle that specifies the image area.
 *  @param origin          The Point that specifies the origin.
 *  @param parent          The parent (if any) of this raster.
 */
public ByteBandedRaster(SampleModel sampleModel,
                        DataBuffer dataBuffer,
                        Rectangle aRegion,
                        Point origin,
                        ByteBandedRaster parent) {

    super(sampleModel, dataBuffer, aRegion, origin, parent);
    this.maxX = minX + width;
    this.maxY = minY + height;

    if (!(dataBuffer instanceof DataBufferByte)) {
       throw new RasterFormatException("ByteBandedRaster must have" +
            "byte DataBuffers");
    }
    DataBufferByte dbb = (DataBufferByte)dataBuffer;

    if (sampleModel instanceof BandedSampleModel) {
        BandedSampleModel bsm = (BandedSampleModel)sampleModel;
        this.scanlineStride = bsm.getScanlineStride();
        int bankIndices[] = bsm.getBankIndices();
        int bandOffsets[] = bsm.getBandOffsets();
        int dOffsets[] = dbb.getOffsets();
        dataOffsets = new int[bankIndices.length];
        data = new byte[bankIndices.length][];
        int xOffset = aRegion.x - origin.x;
        int yOffset = aRegion.y - origin.y;
        for (int i = 0; i < bankIndices.length; i++) {
           data[i] = stealData(dbb, bankIndices[i]);
           dataOffsets[i] = dOffsets[bankIndices[i]] +
               xOffset + yOffset*scanlineStride + bandOffsets[i];
        }
    } else {
        throw new RasterFormatException("ByteBandedRasters must have"+
            "BandedSampleModels");
    }
    verify();
}
 
Example 38
Project: JavaGraph   File: LayoutMap.java   View source code 5 votes vote down vote up
/**
 * Converts a list of points to the minimal rectangle containing all of
 * them.
 */
static public Rectangle toBounds(List<Point2D> points) {
    Rectangle bounds = new Rectangle();
    for (Point2D point : points) {
        bounds.add(point);
    }
    return bounds;

}
 
Example 39
Project: openjdk-jdk10   File: JComponentOperator.java   View source code 5 votes vote down vote up
/**
 * Maps {@code JComponent.scrollRectToVisible(Rectangle)} through queue
 */
public void scrollRectToVisible(final Rectangle rectangle) {
    runMapping(new MapVoidAction("scrollRectToVisible") {
        @Override
        public void map() {
            ((JComponent) getSource()).scrollRectToVisible(rectangle);
        }
    });
}
 
Example 40
Project: incubator-netbeans   File: DropdownButton.java   View source code 5 votes vote down vote up
public void paint(Graphics g) {
    Rectangle c = g.getClipBounds();
    if (pushed || !isEnabled() || container.getComponent(0) != this)
        g.setClip(0, 0, getWidth() - POPUP_EXTENT, getHeight());
    super.paint(g);
    g.setClip(c);
}