本文整理汇总了Java中java.awt.geom.RectangularShape类的典型用法代码示例。如果您正苦于以下问题:Java RectangularShape类的具体用法?Java RectangularShape怎么用?Java RectangularShape使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RectangularShape类属于java.awt.geom包,在下文中一共展示了RectangularShape类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: paintComponent
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Draws the component background.
*
* @param g
* the graphics context
*/
void paintComponent(Graphics g) {
RectangularShape rectangle;
int radius = RapidLookAndFeel.CORNER_DEFAULT_RADIUS;
switch (position) {
case SwingConstants.LEFT:
rectangle = new RoundRectangle2D.Double(0, 0, button.getWidth() + radius, button.getHeight(), radius,
radius);
break;
case SwingConstants.CENTER:
rectangle = new Rectangle2D.Double(0, 0, button.getWidth(), button.getHeight());
break;
default:
rectangle = new RoundRectangle2D.Double(-radius, 0, button.getWidth() + radius, button.getHeight(), radius,
radius);
break;
}
RapidLookTools.drawButton(button, g, rectangle);
}
示例2: paintBar
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
*/
@Override
public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base) {
Paint itemPaint = renderer.getItemPaint(row, column);
GradientPaintTransformer t = renderer.getGradientPaintTransformer();
if (t != null && itemPaint instanceof GradientPaint) {
itemPaint = t.transform((GradientPaint) itemPaint, bar);
}
g2.setPaint(itemPaint);
g2.fill(bar);
// draw the outline...
if (renderer.isDrawBarOutline()) {
// && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
Stroke stroke = renderer.getItemOutlineStroke(row, column);
Paint paint = renderer.getItemOutlinePaint(row, column);
if (stroke != null && paint != null) {
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(bar);
}
}
}
示例3: paintBarShadow
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
* @param pegShadow peg the shadow to the base of the bar?
*/
@Override
public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {
// handle a special case - if the bar colour has alpha == 0, it is
// invisible so we shouldn't draw any shadow
Paint itemPaint = renderer.getItemPaint(row, column);
if (itemPaint instanceof Color) {
Color c = (Color) itemPaint;
if (c.getAlpha() == 0) {
return;
}
}
RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
renderer.getShadowYOffset(), base, pegShadow);
g2.setPaint(Color.gray);
g2.fill(shadow);
}
示例4: splitVerticalBar
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Splits a bar into subregions (elsewhere, these subregions will have
* different gradients applied to them).
*
* @param bar the bar shape.
* @param a the first division.
* @param b the second division.
* @param c the third division.
*
* @return An array containing four subregions.
*/
private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a,
double b, double c) {
Rectangle2D[] result = new Rectangle2D[4];
double x0 = bar.getMinX();
double x1 = Math.rint(x0 + (bar.getWidth() * a));
double x2 = Math.rint(x0 + (bar.getWidth() * b));
double x3 = Math.rint(x0 + (bar.getWidth() * c));
result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(),
x1 - x0, bar.getHeight());
result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1,
bar.getHeight());
result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2,
bar.getHeight());
result[3] = new Rectangle2D.Double(x3, bar.getMinY(),
bar.getMaxX() - x3, bar.getHeight());
return result;
}
示例5: splitHorizontalBar
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Splits a bar into subregions (elsewhere, these subregions will have
* different gradients applied to them).
*
* @param bar the bar shape.
* @param a the first division.
* @param b the second division.
* @param c the third division.
*
* @return An array containing four subregions.
*/
private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a,
double b, double c) {
Rectangle2D[] result = new Rectangle2D[4];
double y0 = bar.getMinY();
double y1 = Math.rint(y0 + (bar.getHeight() * a));
double y2 = Math.rint(y0 + (bar.getHeight() * b));
double y3 = Math.rint(y0 + (bar.getHeight() * c));
result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(),
bar.getWidth(), y1 - y0);
result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(),
y2 - y1);
result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(),
y3 - y2);
result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(),
bar.getMaxY() - y3);
return result;
}
示例6: paintBarShadow
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
* @param pegShadow peg the shadow to the base of the bar?
*/
@Override
public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {
// handle a special case - if the bar colour has alpha == 0, it is
// invisible so we shouldn't draw any shadow
Paint itemPaint = renderer.getItemPaint(row, column);
if (itemPaint instanceof Color) {
Color c = (Color) itemPaint;
if (c.getAlpha() == 0) {
return;
}
}
RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
renderer.getShadowYOffset(), base, pegShadow);
g2.setPaint(renderer.getShadowPaint());
g2.fill(shadow);
}
示例7: paintBar
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
*/
@Override
public void paintBar(Graphics2D g2, BarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base) {
Paint itemPaint = renderer.getItemPaint(row, column);
GradientPaintTransformer t = renderer.getGradientPaintTransformer();
if (t != null && itemPaint instanceof GradientPaint) {
itemPaint = t.transform((GradientPaint) itemPaint, bar);
}
g2.setPaint(itemPaint);
g2.fill(bar);
// draw the outline...
if (renderer.isDrawBarOutline()) {
// && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
Stroke stroke = renderer.getItemOutlineStroke(row, column);
Paint paint = renderer.getItemOutlinePaint(row, column);
if (stroke != null && paint != null) {
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(bar);
}
}
}
示例8: paintBarShadow
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
* @param pegShadow peg the shadow to the base of the bar?
*/
@Override
public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {
// handle a special case - if the bar colour has alpha == 0, it is
// invisible so we shouldn't draw any shadow
Paint itemPaint = renderer.getItemPaint(row, column);
if (itemPaint instanceof Color) {
Color c = (Color) itemPaint;
if (c.getAlpha() == 0) {
return;
}
}
RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
renderer.getShadowYOffset(), base, pegShadow);
g2.setPaint(Color.GRAY);
g2.fill(shadow);
}
示例9: paintHandles
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paint the handles onto a Graphics object.
*
* @param g2d
* @param handleSize The width & height of the shape used to draw the handles
* @param colorStroke
* @param colorFill
*/
public static void paintHandles(final List<Point2> handles, final Graphics2D g2d, final double handleSize, final Color colorStroke, final Color colorFill) {
RectangularShape handleShape = new Rectangle2D.Double();
// handleShape = new Ellipse2D.Double();
for (Point2 p : handles) {
handleShape.setFrame(p.getX()-handleSize/2, p.getY()-handleSize/2, handleSize, handleSize);
if (colorFill != null) {
g2d.setColor(colorFill);
g2d.fill(handleShape);
}
if (colorStroke != null) {
g2d.setColor(colorStroke);
g2d.draw(handleShape);
}
}
}
示例10: convert
import java.awt.geom.RectangularShape; //导入依赖的package包/类
public Shape convert(char c, RectangularShape bar)
{
FontRenderContext frc = getFontMetrics(f).getFontRenderContext();
GlyphVector v = f.createGlyphVector(frc, new char[] { c });
// Scale letter to fit the bar bounds
AffineTransform at = new AffineTransform();
at.scale( bar.getBounds2D().getWidth() / v.getOutline().getBounds2D().getWidth() , bar.getBounds2D().getHeight() / v.getOutline().getBounds2D().getHeight() );
v.setGlyphTransform(0, at);
// Convert into shape
Shape letter = v.getOutline( (float) bar.getBounds2D().getMinX() , (float) (bar.getBounds2D().getMinY() + bar.getBounds2D().getHeight()) );
//make fine adjustments to fit bar boundaries
double difference_x = bar.getBounds2D().getX() - letter.getBounds2D().getX();
double difference_y = bar.getBounds2D().getY() - letter.getBounds2D().getY();
// Reassign with refinements
letter = v.getOutline( (float) bar.getBounds2D().getMinX() + (float) difference_x , (float) (bar.getBounds2D().getMinY() + bar.getBounds2D().getHeight() + difference_y) );
return letter;
}
示例11: paintBar
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
*/
public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base) {
Paint itemPaint = renderer.getItemPaint(row, column);
GradientPaintTransformer t = renderer.getGradientPaintTransformer();
if (t != null && itemPaint instanceof GradientPaint) {
itemPaint = t.transform((GradientPaint) itemPaint, bar);
}
g2.setPaint(itemPaint);
g2.fill(bar);
// draw the outline...
if (renderer.isDrawBarOutline()) {
// && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) {
Stroke stroke = renderer.getItemOutlineStroke(row, column);
Paint paint = renderer.getItemOutlinePaint(row, column);
if (stroke != null && paint != null) {
g2.setStroke(stroke);
g2.setPaint(paint);
g2.draw(bar);
}
}
}
示例12: paintBarShadow
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
* @param pegShadow peg the shadow to the base of the bar?
*/
public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {
// handle a special case - if the bar colour has alpha == 0, it is
// invisible so we shouldn't draw any shadow
Paint itemPaint = renderer.getItemPaint(row, column);
if (itemPaint instanceof Color) {
Color c = (Color) itemPaint;
if (c.getAlpha() == 0) {
return;
}
}
RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
renderer.getShadowYOffset(), base, pegShadow);
g2.setPaint(Color.gray);
g2.fill(shadow);
}
示例13: paintBarShadow
import java.awt.geom.RectangularShape; //导入依赖的package包/类
/**
* Paints a single bar instance.
*
* @param g2 the graphics target.
* @param renderer the renderer.
* @param row the row index.
* @param column the column index.
* @param bar the bar
* @param base indicates which side of the rectangle is the base of the
* bar.
* @param pegShadow peg the shadow to the base of the bar?
*/
public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row,
int column, RectangularShape bar, RectangleEdge base,
boolean pegShadow) {
// handle a special case - if the bar colour has alpha == 0, it is
// invisible so we shouldn't draw any shadow
Paint itemPaint = renderer.getItemPaint(row, column);
if (itemPaint instanceof Color) {
Color c = (Color) itemPaint;
if (c.getAlpha() == 0) {
return;
}
}
RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(),
renderer.getShadowYOffset(), base, pegShadow);
g2.setPaint(renderer.getShadowPaint());
g2.fill(shadow);
}