use of org.eclipse.swt.graphics.Region in project tdi-studio-se by Talend.
the class Marker method getHoverRegion.
/**
* Gets the hover region. The direction of hover arrow can be changed so that hover is completely shown within
* screen.
*
* @param textExtent The text extent
* @param showOnRight <tt>true</tt> to show hover on the right hand side of data point
* @param showBelow <tt>true</tt> to show hover below data point
* @return The hover region
*/
private static Region getHoverRegion(Point textExtent, boolean showOnRight, boolean showBelow) {
Region region = new Region();
int[] pointArray;
if (showOnRight && showBelow) {
pointArray = new int[] { 0, 0, OFFSET + 5, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, textExtent.y + OFFSET, OFFSET, textExtent.y + OFFSET, OFFSET, OFFSET + 5, 0, 0 };
} else if (!showOnRight && showBelow) {
pointArray = new int[] { OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET - 5, OFFSET, textExtent.x + MARGIN * 2 + OFFSET * 2, 0, textExtent.x + MARGIN * 2 + OFFSET, OFFSET + 5, textExtent.x + MARGIN * 2 + OFFSET, textExtent.y + OFFSET, OFFSET, textExtent.y + OFFSET, OFFSET, OFFSET };
} else if (showOnRight && !showBelow) {
pointArray = new int[] { OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, textExtent.y + OFFSET, OFFSET + 5, textExtent.y + OFFSET, 0, textExtent.y + OFFSET * 2, OFFSET, textExtent.y + OFFSET - 5, OFFSET, OFFSET };
} else /* if (!showOnRight && !showBelow) */
{
pointArray = new int[] { OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, OFFSET, textExtent.x + MARGIN * 2 + OFFSET, textExtent.y + OFFSET - 5, textExtent.x + MARGIN * 2 + OFFSET * 2, textExtent.y + OFFSET * 2, textExtent.x + MARGIN * 2 + OFFSET - 5, textExtent.y + OFFSET, OFFSET, textExtent.y + OFFSET, OFFSET, OFFSET };
}
region.add(pointArray);
return region;
}
use of org.eclipse.swt.graphics.Region in project tdi-studio-se by Talend.
the class Marker method createHovers.
/**
* Creates the hovers.
*/
private void createHovers() {
// create hover keys
List<String> keys = new ArrayList<String>();
keys.add(TIME_KEY);
for (ISeries series : chart.getSeriesSet().getSeries()) {
keys.add(series.getId());
}
// create or reuse hovers
Map<String, Shell> newHovers = new HashMap<String, Shell>();
for (final String key : keys) {
Shell hover = hovers.get(key);
if (hover == null) {
hover = createHover(key);
}
newHovers.put(key, hover);
}
// dispose unused hovers
for (Entry<String, Shell> entrySet : hovers.entrySet()) {
if (!keys.contains(entrySet.getKey())) {
Shell hover = entrySet.getValue();
Region region = hover.getRegion();
if (region != null) {
region.dispose();
}
hover.dispose();
}
}
hovers = newHovers;
}
use of org.eclipse.swt.graphics.Region in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_widgets_Shell method a_test_setRegion.
// TODO This test was not hooked for running with the runTest override. It fails on GTK/Cocoa. Investigate.
public void a_test_setRegion() {
Region region = new Region();
region.add(new Rectangle(10, 20, 100, 200));
// test shell without style SWT.NO_TRIM
assertNull(":a:", shell.getRegion());
shell.setRegion(region);
assertNull(":b:", shell.getRegion());
shell.setRegion(null);
assertNull(":c:", shell.getRegion());
// test shell with style SWT.NO_TRIM
Display display = shell.getDisplay();
Shell shell2 = new Shell(display, SWT.NO_TRIM);
assertNull(":d:", shell2.getRegion());
shell2.setRegion(region);
assertTrue(":e:", shell2.getRegion().handle == region.handle);
region.dispose();
assertTrue(":f:", shell2.getRegion().isDisposed());
shell2.setRegion(null);
assertNull(":g:", shell2.getRegion());
}
use of org.eclipse.swt.graphics.Region in project knime-core by knime.
the class KNIMECTabFolderRenderer method drawTabHeader.
void drawTabHeader(final GC gc, final Rectangle bounds, final int state) {
// gc.setClipping(bounds.x, bounds.y, bounds.width,
// parent.getTabHeight() + 1);
boolean onBottom = parent.getTabPosition() == SWT.BOTTOM;
int[] points = new int[1024];
int index = 0;
int radius = cornerSize / 2;
int marginWidth = parent.marginWidth;
int marginHeight = parent.marginHeight;
int delta = INNER_KEYLINE + OUTER_KEYLINE + 2 * (shadowEnabled ? SIDE_DROP_WIDTH : 0) + 2 * marginWidth;
int width = bounds.width - delta;
int height = bounds.height - INNER_KEYLINE - OUTER_KEYLINE - 2 * marginHeight - (shadowEnabled ? BOTTOM_DROP_WIDTH : 0);
int circX = bounds.x + delta / 2 + radius;
int circY = bounds.y + radius;
// Fill in background
Region clipping = new Region();
gc.getClipping(clipping);
Region region = new Region();
region.add(shape);
region.intersect(clipping);
gc.setClipping(region);
// TODO: this needs
int header = shadowEnabled ? onBottom ? 6 : 3 : 1;
// to be added to
// computeTrim for
// HEADER
Rectangle trim = computeTrim(PART_HEADER, state, 0, 0, 0, 0);
trim.width = bounds.width - trim.width;
// XXX: The magic numbers need to be cleaned up. See https://bugs.eclipse.org/425777 for details.
trim.height = (parent.getTabHeight() + (onBottom ? 7 : 4)) - trim.height;
trim.x = -trim.x;
trim.y = onBottom ? bounds.height - parent.getTabHeight() - 1 - header : -trim.y;
draw(PART_BACKGROUND, SWT.NONE, trim, gc);
gc.setClipping(clipping);
clipping.dispose();
region.dispose();
int[] ltt = drawCircle(circX + 1, circY + 1, radius, LEFT_TOP);
System.arraycopy(ltt, 0, points, index, ltt.length);
index += ltt.length;
int[] lbb = drawCircle(circX + 1, circY + height - (radius * 2) - 2, radius, LEFT_BOTTOM);
System.arraycopy(lbb, 0, points, index, lbb.length);
index += lbb.length;
int[] rb = drawCircle(circX + width - (radius * 2) - 2, circY + height - (radius * 2) - 2, radius, RIGHT_BOTTOM);
System.arraycopy(rb, 0, points, index, rb.length);
index += rb.length;
int[] rt = drawCircle(circX + width - (radius * 2) - 2, circY + 1, radius, RIGHT_TOP);
System.arraycopy(rt, 0, points, index, rt.length);
index += rt.length;
points[index++] = points[0];
points[index++] = points[1];
int[] tempPoints = new int[index];
System.arraycopy(points, 0, tempPoints, 0, index);
if (outerKeyline == null) {
outerKeyline = gc.getDevice().getSystemColor(SWT.COLOR_BLACK);
}
gc.setForeground(outerKeyline);
gc.drawPolyline(shape);
}
use of org.eclipse.swt.graphics.Region in project eclipse.platform.swt by eclipse.
the class RegionClippingTab method paint.
@Override
public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics())
return;
Device device = gc.getDevice();
// array of coordinate points of polygon 1 (region 1)
int[] polygon1 = new int[] { 10, height / 2, 9 * width / 16, 10, 9 * width / 16, height - 10 };
Region region1 = new Region(device);
region1.add(polygon1);
// array of coordinate points of polygon 2 (region 2)
int[] polygon2 = new int[] { 9 * width / 16, 10, 9 * width / 16, height / 8, 7 * width / 16, 2 * height / 8, 9 * width / 16, 3 * height / 8, 7 * width / 16, 4 * height / 8, 9 * width / 16, 5 * height / 8, 7 * width / 16, 6 * height / 8, 9 * width / 16, 7 * height / 8, 9 * width / 16, height - 10, width - 10, height / 2 };
Region region2 = new Region(device);
region2.add(polygon2);
gc.setAlpha(127);
int clippingIndex = clippingCb.getSelectionIndex();
switch(clippingIndex) {
case 0:
// region 1
gc.setClipping(region1);
gc.setBackground(colorGB1.getBgColor1());
gc.fillPolygon(polygon1);
break;
case 1:
// region 2
gc.setClipping(region2);
gc.setBackground(colorGB2.getBgColor1());
gc.fillPolygon(polygon2);
break;
case 2:
// add
region1.add(region2);
break;
case 3:
// sub
region1.subtract(region2);
break;
case 4:
// intersect
region1.intersect(region2);
break;
}
if (clippingIndex > 1) {
gc.setClipping(region1);
gc.setBackground(colorGB1.getBgColor1());
gc.fillPolygon(polygon1);
gc.setBackground(colorGB2.getBgColor1());
gc.fillPolygon(polygon2);
}
region1.dispose();
region2.dispose();
}
Aggregations