public polygon getInteriorpolygon(Component c) {
NimbusEditorTabcellRenderer ren = (NimbusEditorTabcellRenderer) c;
Insets ins = getBorderInsets(c);
polygon p = new polygon();
int x = ren.isLeftmost() ? 3 : 0;
int y = 0;
int width = ren.isLeftmost() ? c.getWidth() - 3 : c.getWidth();
int height = c.getHeight() - 4;
//Modified to return rectangle
p.addPoint(x,y);
p.addPoint(x + width,y + height);
p.addPoint(x,y + height);
return p;
}
项目:jdk8u-jdk
文件:UnmanagedDrawImagePerformance.java
private static long test(Image bi,Image vi,AffineTransform atfm) {
final polygon p = new polygon();
p.addPoint(0,0);
p.addPoint(SIZE,0);
p.addPoint(0,SIZE);
p.addPoint(SIZE,SIZE);
p.addPoint(0,0);
Graphics2D g2d = (Graphics2D) vi.getGraphics();
g2d.clip(p);
g2d.transform(atfm);
g2d.setComposite(AlphaComposite.SrcOver);
final long start = System.nanoTime();
g2d.drawImage(bi,null);
final long time = System.nanoTime() - start;
g2d.dispose();
return time;
}
public polygon getInteriorpolygon(Component c) {
NimbusEditorTabcellRenderer ren = (NimbusEditorTabcellRenderer) c;
Insets ins = getBorderInsets(c);
polygon p = new polygon();
int x = 0;
int y = 0;
int width = c.getWidth() + 10;
int height = c.getHeight() - 4;
//Modified to return rectangle
p.addPoint(x,y + height);
return p;
}
项目:brModelo
文件:LivreBase.java
public Shape getRegiaoComentario() {
if (Regiao == null) {
GeneralPath pa = new GeneralPath();
pa.setwindingRule(GeneralPath.WIND_NON_ZERO);
Rectangle rec = getBounds();
int tam = Math.min(rec.width / 6,rec.height / 6);
int curv = tam / 4;
int lw = rec.x + rec.width;
int[] px = new int[]{rec.x,lw - tam,lw,rec.x};
int[] py = new int[]{rec.y,rec.y,rec.y + tam,rec.y + rec.height,rec.y + rec.height};
polygon po = new polygon(px,py,5);
pa.append(po,true);
pa.moveto(lw - tam,rec.y);
pa.curveto(lw - tam,lw - tam + curv,rec.y + curv,rec.y + tam - (1));
pa.moveto(lw - tam,rec.y + tam - (1));
pa.lineto(lw,rec.y + tam);
pa.closePath();
Regiao = pa;
}
return Regiao;
}
项目:jmt
文件:PainterConvex2D.java
/**
* Draw a semi-trasparet area
* @param g The graphic object
* @param dragPoint The first point
* @param beginPoint The second point
* @param c The color of the area
*/
public void drawDragArea(Graphics2D g,Point dragPoint,Point beginPoint,Color c) {
g.setColor(c);
polygon poly = new polygon();
poly.addPoint((int) beginPoint.getX(),(int) beginPoint.getY());
poly.addPoint((int) beginPoint.getX(),(int) dragPoint.getY());
poly.addPoint((int) dragPoint.getX(),(int) beginPoint.getY());
//Set the widths of the shape's outline
stroke oldStro = g.getstroke();
stroke stroke = new Basicstroke(2.0f,Basicstroke.CAP_ROUND,Basicstroke.JOIN_ROUND);
g.setstroke(stroke);
g.drawpolygon(poly);
g.setstroke(oldStro);
//Set the trasparency of the iside of the rectangle
Composite oldComp = g.getComposite();
Composite alphaComp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.4f);
g.setComposite(alphaComp);
g.fillpolygon(poly);
g.setComposite(oldComp);
}
项目:Tarski
文件:mxRhombusShape.java
/**
*
*/
public Shape createShape(mxGraphics2DCanvas canvas,mxCellState state) {
Rectangle temp = state.getRectangle();
int x = temp.x;
int y = temp.y;
int w = temp.width;
int h = temp.height;
int halfWidth = w / 2;
int halfheight = h / 2;
polygon rhombus = new polygon();
rhombus.addPoint(x + halfWidth,y);
rhombus.addPoint(x + w,y + halfheight);
rhombus.addPoint(x + halfWidth,y + h);
rhombus.addPoint(x,y + halfheight);
return rhombus;
}
项目:openjdk-jdk10
文件:UnmanagedDrawImagePerformance.java
项目:Pixie
文件:ResizeTest.java
/**
* Test of resizedToOriginal for polygon method,of class Resize.
*
* No further tests are done because the resize of the polygon points is
* done based on resizedToOriginal for values methods.
*/
@Test
public void testResizedToOriginal_polygon_01() {
final String testDescription = "----------resizedToOriginalpolygon_01----------\n"
+ " Summary: Test of resizedToOriginal(polygon) method,of class Resize\n"
+ " Description: Check there is no exception when processing null input. Input value null,the resize is set to (1.0,1.0).\n"
+ " Pre-conditions: none\n"
+ " Conditions: none\n"
+ " Expected result: It shall output null; no errors or exceptions shall occur.\n";
System.out.println(testDescription);
polygon polyResized = null;
Resize instance = new Resize(1.0,1.0);
polygon expResult = null;
polygon result = instance.resizedToOriginal(polyResized);
assertEquals(expResult,result);
}
public void mousepressed(MouseEvent e) {
if (station){
//This will detect if the mouse clicks on a datapoint
//and will set the selectedRow value. Used for dragging.
selectedRow = -1;
selectPoint(e);
}
if (e.isControlDown()) return;
if (e.isConsumed()||!map.isSelectable()) return;
if (db.panTB.isSelected()) return;
if (e.isShiftDown()) {
p1=e.getPoint();
p2=new Point(p1.x+1,p1.y+1);
drawSelectionBox();
}
else {
poly = new polygon();
poly.addPoint(e.getPoint().x,e.getPoint().y);
}
}
项目:TrabalhoFinalEDA2
文件:mxRhombusShape.java
/**
*
*/
public Shape createShape(mxGraphics2DCanvas canvas,mxCellState state)
{
Rectangle temp = state.getRectangle();
int x = temp.x;
int y = temp.y;
int w = temp.width;
int h = temp.height;
int halfWidth = w / 2;
int halfheight = h / 2;
polygon rhombus = new polygon();
rhombus.addPoint(x + halfWidth,y);
rhombus.addPoint(x + w,y + halfheight);
rhombus.addPoint(x + halfWidth,y + h);
rhombus.addPoint(x,y + halfheight);
return rhombus;
}
项目:myfaces-trinidad
文件:MapArea.java
/**
* Creates a polygon MapArea
*/
public MapArea(polygon polygon)
{
int[] coords = null;
if ((polygon != null) && (polygon.npoints != 0))
{
coords = new int[polygon.npoints * 2];
for (int i = 0; i < polygon.npoints; i++)
{
coords[i*2] = polygon.xpoints[i];
coords[i*2+1] = polygon.ypoints[i];
}
}
_init(polyGON_SHAPE,coords);
}
private void registerMultipleServices() {
area = new Area();
rectangle = new Rectangle();
polygon = new polygon();
Dictionary polygonProp = new Properties();
polygonProp.put(Constants.SERVICE_RANKING,new Integer(1));
// first register polygon
polygonReg = bundleContext.registerService(Shape.class.getName(),polygon,polygonProp);
// then rectangle
Dictionary rectangleProp = new Properties();
rectangleProp.put(Constants.SERVICE_RANKING,new Integer(10));
rectangleReg = bundleContext.registerService(Shape.class.getName(),rectangle,rectangleProp);
// then area
Dictionary areaProp = new Properties();
areaProp.put(Constants.SERVICE_RANKING,new Integer(100));
areaReg = bundleContext.registerService(Shape.class.getName(),area,areaProp);
}
public void testMultipleInterceptorEquality() throws Exception {
target = new polygon();
Advice interceptorA1 = createInterceptorWOServicerequired();
Advice interceptorA2 = new LocalBundleContextAdvice(bundleContext);
Advice interceptorA3 = new ServiceTcclInterceptor(null);
Advice interceptorB1 = createInterceptorWOServicerequired();
Advice interceptorB2 = new LocalBundleContextAdvice(bundleContext);
Advice interceptorB3 = new ServiceTcclInterceptor(null);
Object proxyA = createProxy(target,Shape.class,new Advice[] { interceptorA1,interceptorA2,interceptorA3 });
Object proxyB = createProxy(target,new Advice[] { interceptorB1,interceptorB2,interceptorB3 });
assertFalse(proxyA == proxyB);
assertEquals(interceptorA1,interceptorB1);
assertEquals(interceptorA2,interceptorB2);
assertEquals(interceptorA3,interceptorB3);
assertEquals(proxyA,proxyB);
}
项目:Tarski
文件:mxMarkerRegistry.java
public mxPoint paintMarker(mxGraphics2DCanvas canvas,mxCellState state,String type,mxPoint pe,double nx,double ny,double size,boolean source) {
polygon poly = new polygon();
poly.addPoint((int) Math.round(pe.getX()),(int) Math.round(pe.getY()));
poly.addPoint((int) Math.round(pe.getX() - nx - ny / 2),(int) Math.round(pe.getY() - ny + nx / 2));
if (type.equals(mxConstants.ARROW_CLASSIC)) {
poly.addPoint((int) Math.round(pe.getX() - nx * 3 / 4),(int) Math.round(pe.getY() - ny * 3 / 4));
}
poly.addPoint((int) Math.round(pe.getX() + ny / 2 - nx),(int) Math.round(pe.getY() - ny - nx / 2));
if (mxUtils.isTrue(state.getStyle(),(source) ? "startFill" : "endFill",true)) {
canvas.fillShape(poly);
}
canvas.getGraphics().draw(poly);
return new mxPoint(-nx,-ny);
}
项目:L2jBrasil
文件:L2Territory.java
public void paintInterior(Graphics g,Component c) {
NimbusEditorTabcellRenderer ren = (NimbusEditorTabcellRenderer) c;
polygon p = getInteriorpolygon(c);
Rectangle bounds = p.getBounds();
int yDiff = getHeightDifference(ren);
paintTabBackground(g,c,bounds.x,bounds.y + yDiff,bounds.width,bounds.height - yDiff);
if (!supportsCloseButton((JComponent)c)) {
return;
}
paintCloseButton( g,(JComponent)c );
}
@Override
public polygon getExactTabIndication(int index) {
// TBD - the same code is copied in ScrollableTabsUI,should be shared
// if will not differ
// GeneralPath indication = new GeneralPath();
JComponent control = getdisplayer();
int height = control.getHeight();
TabLayoutModel tlm = getLayoutModel();
int tabXStart = tlm.getX(index);
int tabXEnd = tabXStart + tlm.getW(index);
int[] xpoints = new int[4];
int[] ypoints = new int[4];
xpoints[0] = tabXStart;
ypoints[0] = 0;
xpoints[1] = tabXEnd;
ypoints[1] = 0;
xpoints[2] = tabXEnd;
ypoints[2] = height - 1;
xpoints[3] = tabXStart;
ypoints[3] = height - 1;
return new Equalpolygon(xpoints,ypoints);
}
@Override
public polygon getInsertTabIndication(int index) {
Equalpolygon indication = new Equalpolygon();
JComponent control = getdisplayer();
int height = control.getHeight();
int width = control.getWidth();
TabLayoutModel tlm = getLayoutModel();
int tabXStart;
int tabXEnd;
if (index == 0) {
tabXStart = 0;
tabXEnd = tlm.getW(0) / 2;
} else if (index >= getDataModel().size()) {
tabXStart = tlm.getX(index - 1) + tlm.getW(index - 1) / 2;
tabXEnd = tabXStart + tlm.getW(index - 1);
if (tabXEnd > width) {
tabXEnd = width;
}
} else {
tabXStart = tlm.getX(index - 1) + tlm.getW(index - 1) / 2;
tabXEnd = tlm.getX(index) + tlm.getW(index) / 2;
}
indication.moveto(tabXStart,0);
indication.lineto(tabXEnd,height - 1);
indication.lineto(tabXStart,height - 1);
return indication;
}
项目:jdk8u-jdk
文件:BasicIconFactory.java
@Override
public Shape createShape(double x,double y) {
int[] xPoints = new int[] { (int) Math.ceil(x - POINTSIZE / 2.0d),(int) Math.ceil(x),(int) Math.ceil(x + POINTSIZE / 2.0d) };
int[] yPoints = new int[] { (int) Math.ceil(y + POINTSIZE / 2.0d),(int) Math.ceil(y - POINTSIZE / 2.0d),(int) Math.ceil(y + POINTSIZE / 2.0d) };
return new polygon(xPoints,yPoints,xPoints.length);
}
@Override
public Shape createShape(double x,(int) Math.ceil(x + POINTSIZE / 2.0d) };
int[] yPoints = new int[] { (int) Math.ceil(y - POINTSIZE / 2.0d),(int) Math.ceil(y + POINTSIZE / 2.0d),(int) Math.ceil(y - POINTSIZE / 2.0d) };
return new polygon(xPoints,xPoints.length);
}
项目:jdk8u-jdk
文件:CSSBorder.java
private static void paintSelectedRight(Graphics g,int y,int w,int h) {
g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[2]);
g.drawLine(x,y + 1,x + w - 11,y + 1);
g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[3]);
g.drawLine(x,y,x + w - 15,y);
ColorUIResource c1 = RapidLookTools.getColors().getTabbedPaneColors()[4];
g.setColor(c1);
g.drawLine(w + x - 10,w + x - 10,y + 2);
g.drawLine(w + x - 9,y + 2,w + x - 9,y + 2);
g.drawLine(w + x - 8,w + x - 8,y + 3);
g.drawLine(w + x - 7,y + 3,w + x - 7,y + 4);
g.drawLine(w + x - 6,y + 4,w + x - 6,y + 5);
g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[5]);
g.drawLine(x,y + 2);
g.drawLine(x,x + w - 9,y + 3);
g.drawLine(x,x + w - 8,y + 4);
g.drawLine(x,y + 5,x + w - 7,y + 5);
Graphics2D g2 = (Graphics2D) g;
g2.setPaint(new GradientPaint(1,y + 6,RapidLookTools.getColors().getTabbedPaneColors()[6],1,y + h,RapidLookTools.getColors().getTabbedPaneColors()[7]));
int[] xArr = new int[] { x + 4,w + x - 5,x + 4 };
int[] yArr = new int[] { y + 6,y + h };
polygon p1 = new polygon(xArr,yArr,4);
g2.fillpolygon(p1);
g.setColor(c1);
g.drawLine(w + x - 5,x + w - 5,y + h - 1);
g.setColor(RapidLookTools.getColors().getTabbedPaneColors()[1]);
g.drawLine(x + w - 14,x + w - 12,y);
g.drawLine(w + x - 6,x + w - 6,y + 6);
}
protected void paintTabBackground(Graphics g,int tabPlacement,int tabIndex,int h,boolean isSelected)
{
polygon shape = new polygon();
shape.addPoint(x - (h / 4),y + h);
shape.addPoint(x + (h / 4),y);
shape.addPoint(x + w - (h / 4),y);
if (isSelected || (tabIndex == (rects.length - 1)))
{
if (isSelected)
{
g.setColor(selectedColor);
}
else
{
g.setColor(unselectedColor);
}
shape.addPoint(x + w + (h / 4),y + h);
}
else
{
g.setColor(unselectedColor);
shape.addPoint(x + w,y + (h / 2));
shape.addPoint(x + w - (h / 4),y + h);
}
g.fillpolygon(shape);
}
public void paint(polygon shape,int side) {
Rectangle r = shape.getBounds();
int length = Math.max(r.height / 2,length };
Color[] colorPattern =
((side + 1) % 4 < 2) == (type == Value.GROOVE) ?
new Color[] { getShadowColor(color),getLightColor(color) } :
new Color[] { getLightColor(color),getShadowColor(color) };
paintstrokes(r,colorPattern);
}
项目:rapidminer
文件:SeriesFormat.java
public static Shape createTurnedTriangular() {
double s = SHAPE_SIZE;
int s_2 = (int) Math.round(s / 2.0);
int[] xPoints = new int[] { -s_2,s_2 };
int[] yPoints = new int[] { -s_2,s_2,-s_2 };
return new polygon(xPoints,xPoints.length);
}
项目:jmt
文件:PerformanceIndices2DGraph.java
public void mouseMoved(MouseEvent ev) {
ArrayList<DPoint>[] util;
util = data.getResults().getutilization();
for (int j = 0; j < data.getStationNames().length; j++) {
DPoint test = this.adjustMousePoint(ev.getX(),ev.getY());
if (stationLabels[j] != null && stationLabels[j].contains(test)) {
setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
return;
}
int i;
for (i = 0; i < util[j].size(); i = i + 2) {
if (!showStation[j])
continue;
DPoint pointA = plane.getTruePoint(util[j].get(i));
DPoint pointB = plane.getTruePoint(util[j].get(i + 1));
polygon rect = new polygon();
rect.addPoint((int) pointA.getX(),(int) pointA.getY() - 16);
rect.addPoint((int) pointA.getX(),(int) pointA.getY() + 16);
rect.addPoint((int) pointB.getX(),(int) pointB.getY() - 16);
rect.addPoint((int) pointB.getX(),(int) pointB.getY() + 16);
if (rect.contains(test)) {
tooltip = test;
repaint();
return;
}
}
}
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
if (tooltip != null) {
tooltip = null;
repaint();
}
}
项目:brModelo
文件:LivreBase.java
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);
Regiao = los;
}
return Regiao;
}
/**
* Plots the data for a given series.
*
* @param g2 the drawing surface.
* @param dataArea the data area.
* @param info collects plot rendering info.
* @param plot the plot.
* @param dataset the dataset.
* @param seriesIndex the series index.
*/
public void drawSeries(Graphics2D g2,Rectangle2D dataArea,PlotRenderingInfo info,PolarPlot plot,XYDataset dataset,int seriesIndex) {
polygon poly = new polygon();
int numPoints = dataset.getItemCount(seriesIndex);
for (int i = 0; i < numPoints; i++) {
double theta = dataset.getXValue(seriesIndex,i);
double radius = dataset.getYValue(seriesIndex,i);
Point p = plot.translateValueThetaradiusToJava2D(theta,radius,dataArea);
poly.addPoint(p.x,p.y);
}
g2.setPaint(getSeriesPaint(seriesIndex));
g2.setstroke(getSeriesstroke(seriesIndex));
if (isSeriesFilled(seriesIndex)) {
Composite savedComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER,0.5f));
g2.fill(poly);
g2.setComposite(savedComposite);
}
else {
g2.draw(poly);
}
}
项目:Tarski
文件:OurPDFWriter.java
/** Draws a shape. */
public OurPDFWriter drawShape(Shape shape,boolean fillOrNot) {
if (shape instanceof polygon) {
polygon obj = (polygon)shape;
for(int i = 0; i < obj.npoints; i++) buf.writes(obj.xpoints[i]).writes(obj.ypoints[i]).write(i==0 ? "m\n" : "l\n");
buf.write("h\n");
} else {
double moveX = 0,moveY = 0,NowX = 0,NowY = 0,pt[] = new double[6];
for(PathIterator it = shape.getPathIterator(null); !it.isDone(); it.next()) switch(it.currentSegment(pt)) {
case PathIterator.SEG_MOVeto:
NowX = moveX = pt[0]; NowY = moveY = pt[1]; buf.writes(NowX).writes(NowY).write("m\n"); break;
case PathIterator.SEG_CLOSE:
NowX = moveX; NowY = moveY; buf.write("h\n"); break;
case PathIterator.SEG_LINeto:
NowX = pt[0]; NowY = pt[1]; buf.writes(NowX).writes(NowY).write("l\n"); break;
case PathIterator.SEG_CUBICTO:
NowX = pt[4]; NowY = pt[5];
buf.writes(pt[0]).writes(pt[1]).writes(pt[2]).writes(pt[3]).writes(NowX).writes(NowY).write("c\n"); break;
case PathIterator.SEG_QUADTO: // Convert quadratic bezier into cubic bezier using de Casteljau algorithm
double px = NowX + (pt[0] - NowX)*(2.0/3.0),qx = px + (pt[2] - NowX)/3.0;
double py = NowY + (pt[1] - NowY)*(2.0/3.0),qy = py + (pt[3] - NowY)/3.0;
NowX = pt[2]; NowY = pt[3];
buf.writes(px).writes(py).writes(qx).writes(qy).writes(NowX).writes(NowY).write("c\n"); break;
}
}
buf.write(fillOrNot ? "f\n" : "S\n");
return this;
}
项目:jmt
文件:PainterConvex2D.java
/**
* Create a polygon that is a rectangle draw between two point
* @param xP1 The x of the first point
* @param yP1 The y of the first point
* @param xP2 The x of the second point
* @param yP2 The y of the second point
* @return The rectangle in a polygon object
*/
public polygon twoPointRectangle(int xP1,int yP1,int xP2,int yP2) {
polygon p = new polygon();
p.addPoint(xP1,yP1);
p.addPoint(xP1,yP2);
p.addPoint(xP2,yP1);
return p;
}
/**
* Plots the data for a given series.
*
* @param g2 the drawing surface.
* @param dataArea the data area.
* @param info collects plot rendering info.
* @param plot the plot.
* @param dataset the dataset.
* @param seriesIndex the series index.
*/
public void drawSeries(Graphics2D g2,p.y);
}
g2.setPaint(getSeriesPaint(seriesIndex));
g2.setstroke(getSeriesstroke(seriesIndex));
if (isSeriesFilled(seriesIndex)) {
Composite savedComposite = g2.getComposite();
g2.setComposite(AlphaComposite.getInstance(
AlphaComposite.SRC_OVER,0.5f));
g2.fill(poly);
g2.setComposite(savedComposite);
}
else {
g2.draw(poly);
}
}
public void paint(polygon shape,colorPattern);
}
项目:agar.io
文件:EZ.java
@Override public Shape getBounds() {
tempShape = new polygon(drawShape.xpoints,drawShape.ypoints,drawShape.xpoints.length);
tempShape.translate(-1 * (tempShape.getBounds().x + tempShape.getBounds().width/2),-1 * (tempShape.getBounds().y + tempShape.getBounds().height/2));
return EZElement.boundHelper(tempShape,this);
}
项目:JAddOn
文件:JExpandableTextArea.java
@Override
public void mouseMoved(MouseEvent e) {
final Point p = e.getPoint();
final polygon polygon = getTriangle();
if(polygon.contains(p)){
inTheTriangleZone = true;
this.setCursor(new Cursor(Cursor.SE_RESIZE_CURSOR));
this.repaint();
} else {
inTheTriangleZone = false;
this.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
this.repaint();
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。