Search in sources :

Example 6 with Polygon

use of java.awt.Polygon in project adempiere by adempiere.

the class AdempiereTabbedPaneUI method createCroppedTabClip.

private Polygon createCroppedTabClip(int tabPlacement, Rectangle tabRect, int cropline) {
    int rlen = 0;
    int start = 0;
    int end = 0;
    int ostart = 0;
    switch(tabPlacement) {
        case LEFT:
        case RIGHT:
            rlen = tabRect.width;
            start = tabRect.x;
            end = tabRect.x + tabRect.width;
            ostart = tabRect.y;
            break;
        case TOP:
        case BOTTOM:
        default:
            rlen = tabRect.height;
            start = tabRect.y;
            end = tabRect.y + tabRect.height;
            ostart = tabRect.x;
    }
    int rcnt = rlen / CROP_SEGMENT;
    if (rlen % CROP_SEGMENT > 0) {
        rcnt++;
    }
    int npts = 2 + (rcnt * 8);
    int[] xp = new int[npts];
    int[] yp = new int[npts];
    int pcnt = 0;
    xp[pcnt] = ostart;
    yp[pcnt++] = end;
    xp[pcnt] = ostart;
    yp[pcnt++] = start;
    for (int i = 0; i < rcnt; i++) {
        for (int j = 0; j < xCropLen.length; j++) {
            xp[pcnt] = cropline - xCropLen[j];
            yp[pcnt] = start + (i * CROP_SEGMENT) + yCropLen[j];
            if (yp[pcnt] >= end) {
                yp[pcnt] = end;
                pcnt++;
                break;
            }
            pcnt++;
        }
    }
    if (tabPlacement == SwingConstants.TOP || tabPlacement == SwingConstants.BOTTOM) {
        return new Polygon(xp, yp, pcnt);
    }
    //LEFT or RIGHT
    return new Polygon(yp, xp, pcnt);
}
Also used : Polygon(java.awt.Polygon) Point(java.awt.Point)

Example 7 with Polygon

use of java.awt.Polygon in project adempiere by adempiere.

the class AdempiereTabbedPaneUI method paintTab.

protected void paintTab(Graphics g, int tabPlacement, Rectangle[] rects, int tabIndex, Rectangle iconRect, Rectangle textRect) {
    Rectangle tabRect = rects[tabIndex];
    int selectedIndex = tabPane.getSelectedIndex();
    boolean isSelected = selectedIndex == tabIndex;
    Graphics2D g2 = null;
    Polygon cropShape = null;
    Shape save = null;
    int cropx = 0;
    int cropy = 0;
    if (scrollableTabLayoutEnabled()) {
        if (g instanceof Graphics2D) {
            g2 = (Graphics2D) g;
            // Render visual for cropped tab edge...
            Rectangle viewRect = tabScroller.viewport.getViewRect();
            int cropline;
            switch(tabPlacement) {
                case LEFT:
                case RIGHT:
                    cropline = viewRect.y + viewRect.height;
                    if ((tabRect.y < cropline) && (tabRect.y + tabRect.height > cropline)) {
                        cropShape = createCroppedTabClip(tabPlacement, tabRect, cropline);
                        cropx = tabRect.x;
                        cropy = cropline - 1;
                    }
                    break;
                case TOP:
                case BOTTOM:
                default:
                    cropline = viewRect.x + viewRect.width;
                    if ((tabRect.x < cropline) && (tabRect.x + tabRect.width > cropline)) {
                        cropShape = createCroppedTabClip(tabPlacement, tabRect, cropline);
                        cropx = cropline - 1;
                        cropy = tabRect.y;
                    }
            }
            if (cropShape != null) {
                save = g.getClip();
                g2.clip(cropShape);
            }
        }
    }
    paintTabBackground(g, tabPlacement, tabIndex, tabRect.x, tabRect.y, tabRect.width, tabRect.height, isSelected);
    paintTabBorder(g, tabPlacement, tabIndex, tabRect.x, tabRect.y, tabRect.width, tabRect.height, isSelected);
    String title = tabPane.getTitleAt(tabIndex);
    Font font = tabPane.getFont();
    FontMetrics metrics = g.getFontMetrics(font);
    Icon icon = getIconForTab(tabIndex);
    layoutLabel(tabPlacement, metrics, tabIndex, title, icon, tabRect, iconRect, textRect, isSelected);
    paintText(g, tabPlacement, font, metrics, tabIndex, title, textRect, isSelected);
    paintIcon(g, tabPlacement, tabIndex, icon, iconRect, isSelected);
    paintFocusIndicator(g, tabPlacement, rects, tabIndex, iconRect, textRect, isSelected);
    if (cropShape != null) {
        paintCroppedTabEdge(g, tabPlacement, tabIndex, isSelected, cropx, cropy);
        g.setClip(save);
    }
}
Also used : Shape(java.awt.Shape) FontMetrics(java.awt.FontMetrics) Rectangle(java.awt.Rectangle) Icon(javax.swing.Icon) Polygon(java.awt.Polygon) Point(java.awt.Point) Font(java.awt.Font) Graphics2D(java.awt.Graphics2D)

Example 8 with Polygon

use of java.awt.Polygon in project android by JetBrains.

the class ConnectionDraw method getBottomArrow.

/**
     * Static accessor to the bottom arrow
     *
     * @return return a Polygon representing a bottom arrow
     */
public static Polygon getBottomArrow() {
    if (sBottomArrow == null) {
        sBottomArrow = new Polygon();
        sBottomArrow.addPoint(0, 0);
        sBottomArrow.addPoint(-CONNECTION_ARROW_SIZE, -ARROW_SIDE);
        sBottomArrow.addPoint(+CONNECTION_ARROW_SIZE, -ARROW_SIDE);
    }
    return sBottomArrow;
}
Also used : Polygon(java.awt.Polygon)

Example 9 with Polygon

use of java.awt.Polygon in project android by JetBrains.

the class ConnectionDraw method getLeftArrow.

/**
     * Static accessor to the left arrow
     *
     * @return return a Polygon representing a left arrow
     */
public static Polygon getLeftArrow() {
    if (sLeftArrow == null) {
        sLeftArrow = new Polygon();
        sLeftArrow.addPoint(0, 0);
        sLeftArrow.addPoint(ARROW_SIDE, -CONNECTION_ARROW_SIZE);
        sLeftArrow.addPoint(ARROW_SIDE, +CONNECTION_ARROW_SIZE);
    }
    return sLeftArrow;
}
Also used : Polygon(java.awt.Polygon)

Example 10 with Polygon

use of java.awt.Polygon in project android by JetBrains.

the class ConnectionDraw method getRightArrow.

/**
     * Static accessor to the right arrow
     *
     * @return return a Polygon representing a right arrow
     */
public static Polygon getRightArrow() {
    if (sRightArrow == null) {
        sRightArrow = new Polygon();
        sRightArrow.addPoint(0, 0);
        sRightArrow.addPoint(-ARROW_SIDE, -CONNECTION_ARROW_SIZE);
        sRightArrow.addPoint(-ARROW_SIDE, +CONNECTION_ARROW_SIZE);
    }
    return sRightArrow;
}
Also used : Polygon(java.awt.Polygon)

Aggregations

Polygon (java.awt.Polygon)39 Point (java.awt.Point)15 Graphics2D (java.awt.Graphics2D)11 Color (java.awt.Color)6 Rectangle (java.awt.Rectangle)6 GridPoint (doc.GridPoint)5 BasicStroke (java.awt.BasicStroke)5 Font (java.awt.Font)5 Paint (java.awt.Paint)5 FontMetrics (java.awt.FontMetrics)4 AffineTransform (java.awt.geom.AffineTransform)4 GradientPaint (java.awt.GradientPaint)2 Shape (java.awt.Shape)2 ShapeSpanIterator (sun.java2d.pipe.ShapeSpanIterator)2 BasePoint (gdsc.core.match.BasePoint)1 PolygonRoi (ij.gui.PolygonRoi)1 Roi (ij.gui.Roi)1 AlphaComposite (java.awt.AlphaComposite)1 Component (java.awt.Component)1 Dimension (java.awt.Dimension)1