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   Source Code and License 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   Source Code and License 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: brModelo   File: Forma.java   Source Code and License 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 4
Project: ramus   File: GEFComponent.java   Source Code and License 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 5
Project: openjdk-jdk10   File: DrawTest.java   Source Code and License 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 6
Project: incubator-netbeans   File: ParagraphViewChildren.java   Source Code and License 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 7
Project: geomapapp   File: MapServerA.java   Source Code and License 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 8
Project: Equella   File: LabelSeparator.java   Source Code and License 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 9
Project: allure-java   File: Stepdefs.java   Source Code and License 6 votes vote down vote up
@Attachment(type = "image/png", fileExtension = "png", value = "att")
public byte[] attach() {
    try {
        BufferedImage image = new Robot().createScreenCapture(new Rectangle(Toolkit.getDefaultToolkit().getScreenSize()));
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ImageIO.write(image, "png", baos);
        baos.flush();
        byte[] imageInByte = baos.toByteArray();
        baos.close();
        return imageInByte;
    } catch (AWTException | IOException e) {
        return null;
    }
}
 
Example 10
Project: openjdk-jdk10   File: RobotMultiDPIScreenTest.java   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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   Source Code and License 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: powertext   File: RSyntaxTextArea.java   Source Code and License 5 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 23
Project: GitHub   File: RectangleDeserializerTest.java   Source Code and License 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 24
Project: incubator-netbeans   File: JXTableDecorator.java   Source Code and License 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 25
Project: geomapapp   File: PersTool.java   Source Code and License 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 26
Project: incubator-netbeans   File: TabTable.java   Source Code and License 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 27
Project: VTerminal   File: Screen.java   Source Code and License 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 28
Project: incubator-netbeans   File: Central.java   Source Code and License 5 votes vote down vote up
@Override
public void userResizedEditorAreaBoundsHelp(Rectangle bounds) {
    if(getEditorAreaState() == Constants.EDITOR_AREA_JOINED
    && getEditorAreaBounds().isEmpty()) {
        model.setEditorAreaBoundsUserHelp(bounds);
    }
}
 
Example 29
Project: Progetto-C   File: SheetPanel.java   Source Code and License 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 30
Project: Equella   File: StepDialog.java   Source Code and License 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 31
Project: incubator-netbeans   File: WinClassicViewTabDisplayerUI.java   Source Code and License 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 32
Project: openjdk-jdk10   File: XWM.java   Source Code and License 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 33
Project: jdk8u-jdk   File: VariableHeightLayoutCache.java   Source Code and License 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 34
Project: openjdk-jdk10   File: JTreeOperator.java   Source Code and License 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 35
Project: ramus   File: DataLoader.java   Source Code and License 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 36
Project: incubator-netbeans   File: ProfilerXYTooltipOverlay.java   Source Code and License 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 37
Project: AeroStory   File: MapleMist.java   Source Code and License 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 38
Project: OpenJSharp   File: ByteBandedRaster.java   Source Code and License 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 39
Project: JavaGraph   File: LayoutMap.java   Source Code and License 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 40
Project: openjdk-jdk10   File: JComponentOperator.java   Source Code and License 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 41
Project: incubator-netbeans   File: DropdownButton.java   Source Code and License 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);
}
 
Example 42
Project: VASSAL-src   File: Map.java   Source Code and License 5 votes vote down vote up
/**
 * @return true if the given point may not be a legal location. I.e., if this grid will attempt to snap it to the
 *         nearest grid location
 */
public boolean isLocationRestricted(Point p) {
  Board b = findBoard(p);
  if (b != null) {
    Rectangle r = b.bounds();
    Point snap = new Point(p);
    snap.translate(-r.x, -r.y);
    return b.isLocationRestricted(snap);
  }
  else {
    return false;
  }
}
 
Example 43
Project: Equella   File: SerialRenderer.java   Source Code and License 5 votes vote down vote up
@Override
public void draw(Graphics g, Rectangle bounds)
{
	final int childWidth = bounds.width - (PADDING_SIZE * 2);

	// Start placing children from here...
	int nextY = bounds.y;

	final int childCount = getChildCount();
	for( int i = 0; i < childCount; i++ )
	{
		Renderer child = getChild(i);

		// Determine child boundries
		Rectangle childBound = new Rectangle();
		childBound.x = bounds.x + PADDING_SIZE;
		childBound.y = nextY;
		childBound.width = childWidth;
		childBound.height = child.getSize(g).height;

		// Draw child
		child.draw(g, childBound);

		// Next child Y coordinate.
		nextY += childBound.height;
	}

	int maxY = bounds.y + bounds.height;
	if( nextY < maxY )
	{
		int centreX = (int) bounds.getCenterX();
		g.setColor(ARROW_COLOUR);
		g.drawLine(centreX, nextY, centreX, maxY);
	}
}
 
Example 44
Project: incubator-netbeans   File: EditorFindSupport.java   Source Code and License 5 votes vote down vote up
/**
 * Ensure that the given region will be visible in the view
 * with the appropriate find insets.
 */
private void ensureVisible(JTextComponent c, int startOffset, int endOffset, Insets extraInsets) {
    try {
        Rectangle startBounds = c.modelToView(startOffset);
        Rectangle endBounds = c.modelToView(endOffset);
        if (startBounds != null && endBounds != null) {
            startBounds.add(endBounds);
            if (extraInsets != null) {
                Rectangle visibleBounds = c.getVisibleRect();
                int extraTop = (extraInsets.top < 0)
                    ? -extraInsets.top * visibleBounds.height / 100 // percentage
                    : extraInsets.top * endBounds.height; // line count
                startBounds.y -= extraTop;
                startBounds.height += extraTop;
                startBounds.height += (extraInsets.bottom < 0)
                    ? -extraInsets.bottom * visibleBounds.height / 100 // percentage
                    : extraInsets.bottom * endBounds.height; // line count
                int extraLeft = (extraInsets.left < 0)
                    ? -extraInsets.left * visibleBounds.width / 100 // percentage
                    : extraInsets.left * endBounds.width; // char count
                startBounds.x -= extraLeft;
                startBounds.width += extraLeft;
                startBounds.width += (extraInsets.right < 0)
                    ? -extraInsets.right * visibleBounds.width / 100 // percentage
                    : extraInsets.right * endBounds.width; // char count
            }
            c.scrollRectToVisible(startBounds);
        }
    } catch (BadLocationException e) {
        // do not scroll
    }
}
 
Example 45
Project: OpenJSharp   File: SynthTreeUI.java   Source Code and License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void paintDropLine(Graphics g) {
    JTree.DropLocation loc = tree.getDropLocation();
    if (!isDropLine(loc)) {
        return;
    }

    Color c = (Color)style.get(paintContext, "Tree.dropLineColor");
    if (c != null) {
        g.setColor(c);
        Rectangle rect = getDropLineRect(loc);
        g.fillRect(rect.x, rect.y, rect.width, rect.height);
    }
}
 
Example 46
Project: brModelo   File: InspectorItemSeparador.java   Source Code and License 5 votes vote down vote up
@Override
protected void paintBase(Graphics2D g) {
    if (endOFF) {
        return;
    }
    setArea(null);
    Rectangle r = this.getBounds();
    g.setColor(Color.GRAY);
    g.drawRoundRect(0, 0, r.width - 1, r.height - 1, 10, 10);

    g.setColor(Color.lightGray);
    g.drawRoundRect(5, 5, r.height - 10, r.height - 10, 4,4);

    int met = (r.height - 11) / 2;
    g.setColor(Color.black);
    g.drawLine(7, 6 + met, r.height - 7, 6 + met);
    if ('+' == getEstado()) {
        g.drawLine(6 + met, 7, 6 + met, r.height - 7);
    }

    g.setColor(Color.BLACK);
    Rectangle bkp = g.getClipBounds();
    g.clipRect(0, 0, r.width - 1, r.height);
    if (isSelecionado()) {
        g.setFont(new Font(this.getFont().getFontName(), Font.BOLD, getFont().getSize()));
        g.drawRoundRect(0, 0, r.width - 1, r.height - 1, 10, 10);
    }
    int tmp = (r.width - g.getFontMetrics().stringWidth(getTexto())) / 2;

    g.drawString(getTexto(), tmp, (int) (r.height * 0.72));
    g.setClip(bkp);
}
 
Example 47
Project: jmt   File: EdgeAnimation.java   Source Code and License 5 votes vote down vote up
private void calculateBounds(int margin) {
	int maxX = -1, maxY = -1, minX = -1, minY = -1;
	for (Point anglePoint : anglePoints) {
		if (maxX == -1) {
			maxX = anglePoint.x;
		}
		if (maxY == -1) {
			maxY = anglePoint.y;
		}
		if (minX == -1) {
			minX = anglePoint.x;
		}
		if (minY == -1) {
			minY = anglePoint.y;
		}
		if (anglePoint.x > maxX) {
			maxX = anglePoint.x;
		}
		if (anglePoint.y > maxY) {
			maxY = anglePoint.y;
		}
		if (anglePoint.x < minX) {
			minX = anglePoint.x;
		}
		if (anglePoint.y < minY) {
			minY = anglePoint.y;
		}
	}
	maxX += margin;
	minX -= margin;
	maxY += margin;
	minY -= margin;
	bounds = new Rectangle(minX, minY, maxX - minX, maxY - minY);
}
 
Example 48
Project: MaxSim   File: PolylineRouterV2.java   Source Code and License 5 votes vote down vote up
private static boolean intersects(List<Rectangle> obstacles, Point p0, Point p1) {
    for(Rectangle r : obstacles){
        if(r.intersectsLine(p0.x, p0.y, p1.x, p1.y))
            return true;         
    }
    return false;
}
 
Example 49
Project: incubator-netbeans   File: RectangleEditor.java   Source Code and License 5 votes vote down vote up
/** Abstract method for translating the array of int to value
* which is set to method setValue(XXX)
*/
void setValues(int[] val) {
    if ((val[0] < 0) || (val[1] < 0) || (val[2] < 0) || (val[3] < 0)) {
        String msg = NbBundle.getMessage(DimensionEditor.class, 
            "CTL_NegativeSize"); //NOI18N
        IllegalArgumentException iae = new IllegalArgumentException (
            "Negative value"); //NOI18N
        UIExceptions.annotateUser(iae, iae.getMessage(), msg, null,
                                 new java.util.Date());
        throw iae;

    }
    else
        setValue(new Rectangle(val[0], val[1], val[2], val[3]));
}
 
Example 50
Project: geomapapp   File: MaskGrid.java   Source Code and License 5 votes vote down vote up
public static Grid2D.Boolean or(Grid2D.Boolean m1, Grid2D.Boolean m2) {
	Rectangle b = m1.getBounds();
	Grid2D.Boolean mask = new Grid2D.Boolean( b, m1.getProjection() );
	for( int y=b.y ; y<b.y+b.height ; y++) {
		for( int x=b.x ; x<b.x+b.width ; x++) mask.setValue(x,y,m1.booleanValue(x,y)||m2.booleanValue(x,y));
	}
	return mask;
}
 
Example 51
Project: ramus   File: AbstractTemplate.java   Source Code and License 5 votes vote down vote up
public void paint(final Graphics2D graphics2D, final Rectangle rectangle) {
     if (dataPlugin == null) {
         createChilds(rectangle);
         createPainter(rectangle);
     } else if ((!rect.equals(rectangle)) || refresh) {
         createPainter(rectangle);
     }

     graphics2D.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
             RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
     graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING,
             RenderingHints.VALUE_RENDER_QUALITY);
     /*
      * graphics2D.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
* RenderingHints.VALUE_STROKE_PURE);
* graphics2D.setRenderingHint(RenderingHints.KEY_ALPHA_INTERPOLATION,
* RenderingHints.VALUE_ALPHA_INTERPOLATION_QUALITY);
* graphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
* RenderingHints.VALUE_ANTIALIAS_ON);
* 
* graphics2D.setRenderingHint(RenderingHints.KEY_COLOR_RENDERING,
* RenderingHints.VALUE_COLOR_RENDER_QUALITY);
* 
* graphics2D.setRenderingHint(RenderingHints.KEY_DITHERING,
* RenderingHints.VALUE_DITHER_ENABLE);
*/
     graphics2D.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
             RenderingHints.VALUE_FRACTIONALMETRICS_ON);
     graphics2D.setRenderingHint(RenderingHints.KEY_RENDERING,
             RenderingHints.VALUE_RENDER_QUALITY);

     graphics2D.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
             RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);

     painter.paint(graphics2D, rectangle.getX(), rectangle.getY(), true);
 }
 
Example 52
Project: jdk8u-jdk   File: GeneralCompositePipe.java   Source Code and License 5 votes vote down vote up
public Object startSequence(SunGraphics2D sg, Shape s, Rectangle devR,
                            int[] abox) {
    RenderingHints hints = sg.getRenderingHints();
    ColorModel model = sg.getDeviceColorModel();
    PaintContext paintContext =
        sg.paint.createContext(model, devR, s.getBounds2D(),
                               sg.cloneTransform(),
                               hints);
    CompositeContext compositeContext =
        sg.composite.createContext(paintContext.getColorModel(), model,
                                   hints);
    return new TileContext(sg, paintContext, compositeContext, model);
}
 
Example 53
Project: Equella   File: Z3950Plugin.java   Source Code and License 5 votes vote down vote up
@Override
protected void setupGUI(String t1, String t2)
{
	super.setupGUI(t1, t2);
	attributeEditor = new Z3950AttributesEditor();
	super.remove(secondField);
	super.add(attributeEditor, new Rectangle(2, 1, 1, 1));
}
 
Example 54
Project: jdk8u-jdk   File: OGLUtilities.java   Source Code and License 5 votes vote down vote up
/**
 * Returns the Rectangle describing the OpenGL scissor box on the
 * Java 2D surface associated with the given Graphics object.  When a
 * third-party library is performing OpenGL rendering directly
 * into the visible region of the associated surface, this scissor box
 * must be set to avoid drawing over existing rendering results.
 *
 * Note that the x/y values in the returned Rectangle object represent
 * the lower-left corner of the scissor region, relative to the
 * lower-left corner of the given surface.
 *
 * @param g the Graphics object for the corresponding destination surface;
 * cannot be null
 * @return a Rectangle describing the OpenGL scissor box for the given
 * Graphics object and corresponding destination surface, or null if the
 * given Graphics object is invalid or the clip region is non-rectangular
 */
public static Rectangle getOGLScissorBox(Graphics g) {
    if (!(g instanceof SunGraphics2D)) {
        return null;
    }

    SunGraphics2D sg2d = (SunGraphics2D)g;
    SurfaceData sData = (SurfaceData)sg2d.surfaceData;
    Region r = sg2d.getCompClip();
    if (!r.isRectangular()) {
        // caller probably doesn't know how to handle shape clip
        // appropriately, so just return null (Swing currently never
        // sets a shape clip, but that could change in the future)
        return null;
    }

    // this is the upper-left origin of the scissor box relative to the
    // upper-left origin of the surface (in Java 2D coordinates)
    int x0 = r.getLoX();
    int y0 = r.getLoY();

    // this is the width and height of the scissor region
    int w = r.getWidth();
    int h = r.getHeight();

    // this is the lower-left origin of the scissor box relative to the
    // lower-left origin of the surface (in OpenGL coordinates)
    Rectangle surfaceBounds = sData.getBounds();
    int x1 = x0;
    int y1 = surfaceBounds.height - (y0 + h);

    return new Rectangle(x1, y1, w, h);
}
 
Example 55
Project: VASSAL-src   File: LOS_Thread.java   Source Code and License 5 votes vote down vote up
/**
 * Writes text showing the range
 *
 * @param range the range to display, in whatever units returned
 * by the {@link MapGrid} containing the thread */
public void drawRange(Graphics g, int range) {
  Point mapArrow = map.componentCoordinates(arrow);
  Point mapAnchor = map.componentCoordinates(anchor);
  g.setColor(Color.black);
  g.setFont(RANGE_FONT);
  final FontMetrics fm = g.getFontMetrics();
  final StringBuilder buffer = new StringBuilder();
  int dummy = range;
  while (dummy >= 1) {
    dummy = dummy / 10;
    buffer.append("8");
  }
  if (buffer.length() == 0) {
    buffer.append("8");
  }
  String rangeMess = Resources.getString("LOS_Thread.range");
  int wid = fm.stringWidth(" "+rangeMess+"  "+buffer.toString());
  int hgt = fm.getAscent() + 2;
  int w = mapArrow.x - mapAnchor.x;
  int h = mapArrow.y - mapAnchor.y;
  int x0 = mapArrow.x + (int) ((wid / 2 + 20) * w / Math.sqrt(w * w + h * h));
  int y0 = mapArrow.y + (int) ((hgt / 2 + 20) * h / Math.sqrt(w * w + h * h));
  g.fillRect(x0 - wid / 2, y0 + hgt / 2 - fm.getAscent(), wid, hgt);
  g.setColor(Color.white);
  g.drawString(rangeMess + " " + range,
               x0 - wid / 2 + fm.stringWidth(" "), y0 + hgt / 2);
  lastRangeRect = new Rectangle(x0 - wid / 2, y0 + hgt / 2 - fm.getAscent(), wid+1, hgt+1);
  Point np = map.mapCoordinates(new Point(lastRangeRect.x, lastRangeRect.y));
  lastRangeRect.x = np.x;
  lastRangeRect.y = np.y;
  lastRange = String.valueOf(range);
}
 
Example 56
Project: brModelo   File: LivreBase.java   Source Code and License 5 votes vote down vote up
public Shape getRegiaoLosanglo() {
    if (Regiao == null) {
        Rectangle r = new Rectangle(getLeft(), getTop(), getWidth(), getHeight()); //getBounds();
        Polygon los = new Polygon();
        los.addPoint(r.x, r.y + r.height / 2);
        los.addPoint(r.x + r.width / 2, r.y);
        los.addPoint(r.x + r.width, r.y + r.height / 2);
        los.addPoint(r.x + r.width / 2, r.y + r.height);

        Regiao = los;
    }
    return Regiao;
}
 
Example 57
Project: openjdk-jdk10   File: CrashPaintTest.java   Source Code and License 5 votes vote down vote up
@Override
public PaintContext createContext(ColorModel cm,
                                  Rectangle deviceBounds,
                                  Rectangle2D userBounds,
                                  AffineTransform at,
                                  RenderingHints hints) {

    // Fill bufferedImage using
    final Graphics2D g2d = (Graphics2D) getImage().getGraphics();
    try {
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        g2d.setBackground(Color.PINK);
        g2d.clearRect(0, 0, size, size);

        g2d.setColor(Color.BLUE);
        g2d.drawRect(0, 0, size, size);

        g2d.fillOval(size / 10, size / 10,
                     size * 8 / 10, size * 8 / 10);

    } finally {
        g2d.dispose();
    }

    return super.createContext(cm, deviceBounds, userBounds, at, hints);
}
 
Example 58
Project: brModelo   File: InspectorExtenderEditor.java   Source Code and License 5 votes vote down vote up
@Override
public void paint(Graphics g) {
    super.paint(g);
    //Color bkp = g.getColor();
    Rectangle r = this.getBounds();
    g.setColor(Color.BLACK);
    int re = 0;
    String bonito = "?";
    if (getAcaoTipo() == TipoDeAcao.tpAcaoDlgCor || getAcaoTipo() == TipoDeAcao.tpReadOnlyCor) {
        g.setColor(Color.BLACK);
        g.fillRect(3, 3, r.height - 7, r.height - 7);
        try {
            Color c = util.Utilidades.StringToColor(getTexto());
            g.setColor(c);
            bonito = getTexto();
        } catch (Exception e) {
        }
        g.fillRect(4, 4, r.height - 8, r.height - 8);
        //g.setColor(Color.BLACK);
        //g.drawRect(3, 3, r.height - 7, r.height - 7);
        re = r.height - 1;
    } else {
        bonito = getTexto().replaceAll("\n", " | ");
    }
    //g.setColor(bkp);
    
    Rectangle obkp = g.getClipBounds();

    g.setColor(Color.DARK_GRAY);
    g.setFont(new Font(this.getFont().getFontName(), Font.BOLD, getFont().getSize()));
    g.clipRect(re, 0, r.width - r.height -re - (re == 0? 4: 8), r.height);
    g.drawString(bonito, re + 2, (int) (r.height * 0.72) + 1);
    g.drawLine(0, 0, 0, getHeight());
    g.setClip(obkp);
}
 
Example 59
Project: Spark   File: Collision.java   Source Code and License 5 votes vote down vote up
public static final Rectangle PixelPointWeaponCollision(int PointX, int PointY,
		BufferedImage Img1, int X, int Y, int width, int height, int SrcX,
		int SrcY, int Tolerance)
{
	Rectangle rct = new Rectangle();

	rct.x = PointX;
	rct.y = PointY;
	rct.width = 1;
	rct.height = 1;

	Rectangle rct2 = new Rectangle();

	rct2.x = X + Tolerance;
	rct2.y = Y + Tolerance;
	rct2.width = width - Tolerance;
	rct2.height = height - Tolerance;

	if (rct.intersects(rct2) == true)
	{
		Rectangle intersection = rct.intersection(rct2);

		int Image1StartX = SrcX + (intersection.x - rct2.x);
		int Image1StartY = SrcY + (intersection.y - rct2.y);
		int pixel1 = Img1.getRGB(Image1StartX, Image1StartY);
		int alpha = (pixel1 >> 24) & 0xff;
		int red = (pixel1 >> 16) & 0xff;
		int green = (pixel1 >> 8) & 0xff;
		int blue = (pixel1) & 0xff;

		if (alpha > 0 && !(red == 255 && green == 0 && blue == 0))
		{
			return intersection;
		}
	}

	return null;
}
 
Example 60
Project: jdk8u-jdk   File: CGLSurfaceData.java   Source Code and License 4 votes vote down vote up
@Override
public Rectangle getBounds() {
    Rectangle r = pView.getBounds();
    return new Rectangle(0, 0, r.width, r.height);
}