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);
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations