本文整理汇总了Java中java.awt.geom.RoundRectangle2D.Float方法的典型用法代码示例。如果您正苦于以下问题:Java RoundRectangle2D.Float方法的具体用法?Java RoundRectangle2D.Float怎么用?Java RoundRectangle2D.Float使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.RoundRectangle2D
的用法示例。
在下文中一共展示了RoundRectangle2D.Float方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: installFocusListener
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* <pre>
* 初始化边框焦点监听器
*
* Initializes the border focus listener
* <pre>
*
* @param c
*/
protected void installFocusListener(JComponent c)
{
handle = new LuckComboboxFocusHandle();
isFocusBorder = UIManager.getBoolean(LuckComboBoxUIBundle.ISFOCUSBORDER);
if (isFocusBorder)
{
contentShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);
borderShape = new RoundRectangle2D.Float(0, 0, 0, 0, 8, 8);
c.addMouseListener(handle);
c.addFocusListener(handle);
}
}
示例2: TipNode
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
public TipNode() {
super();
// rounded corners at top
Shape roundRect = new RoundRectangle2D.Float( 0f, 0f, 1f, 1.5f, 0.4f, 0.4f );
// mask out rounded corners at bottom
Shape rect = new Rectangle2D.Float( 0f, 0.5f, 1f, 1f );
// point at the bottom
GeneralPath triangle = new GeneralPath();
triangle.moveTo( 0f, 1.5f );
triangle.lineTo( 0.5f, 2.5f );
triangle.lineTo( 1f, 1.5f );
triangle.closePath();
// constructive area geometry
Area area = new Area( roundRect );
area.add( new Area( rect ) );
area.add( new Area( triangle ) );
setPathTo( area );
setPaint( TIP_COLOR );
setStroke( null );
}
示例3: readObject
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
private void readObject(ObjectInputStream in) throws IOException
{
x = in.readFloat();
y = in.readFloat();
width = in.readFloat();
height = in.readFloat();
rx = in.readFloat();
ry = in.readFloat();
if (rx == 0f && ry == 0f)
{
rect = new Rectangle2D.Float(x, y, width, height);
} else
{
rect = new RoundRectangle2D.Float(x, y, width, height, rx * 2, ry * 2);
}
}
示例4: paint
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
public void paint(Graphics2D g, int x, int y, int width, int height) {
g.setRenderingHints( Thumbnail.qualityHints );
Shape outer, inner;
g.setColor(color);
if(innerCurvature>0 || outerCurvature>0) {
outer = new RoundRectangle2D.Float(x, y, width, height, outerCurvature, outerCurvature);
inner = new RoundRectangle2D.Float(x + thickness, y + thickness, width - thickness*2, height - thickness*2, innerCurvature, innerCurvature);
} else {
outer = new Rectangle(x, y, width, height);
inner = new Rectangle(x + thickness, y + thickness, width - thickness*2, height - thickness*2);
}
AffineTransform tx = g.getTransform();
if(tx.getShearX()==0 && tx.getShearY()==0) {
//this should be faster, but produces pixelated artifacts when rotated
GeneralPath path = new GeneralPath( GeneralPath.WIND_EVEN_ODD );
path.append(outer, false);
path.append(inner, false);
g.fill(path);
} else {
Area area = new Area(outer);
area.subtract(new Area(inner));
g.fill(area);
}
}
示例5: paintBorder
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
@Override
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
Graphics2D g2d = (Graphics2D) g.create();
g2d.setRenderingHints(ProcessDrawer.HI_QUALITY_HINTS);
g2d.setStroke(new BasicStroke(2f));
// clear edges, otherwise they will be in the color of the component background
if (drawRoundFrame && !c.getBackground().equals(c.getParent().getBackground())) {
Shape frame = new Rectangle2D.Float(x + 2, y + 2, width - 4, height - 4);
g2d.setPaint(c.getParent().getBackground());
g2d.draw(frame);
}
g2d.setPaint(paint);
g2d.setFont(new Font("Dialog", Font.BOLD, 21));
if (drawRoundFrame) {
Shape roundFrame = new RoundRectangle2D.Float(x + 2, y + 2, width - 4, height - 4, 10, 10);
g2d.draw(roundFrame);
}
if (number > 0) {
Shape circle = new Ellipse2D.Float(20, 20, 34, 34);
g2d.fill(circle);
g2d.setPaint(Color.WHITE);
g2d.drawString(String.valueOf(number), 29, 44);
}
if (key != null) {
g2d.setPaint(paint);
g2d.drawString(key, 60, 44);
}
g2d.dispose();
}
示例6: insertImage
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* 插入LOGO
*
* @param size 二维码尺寸
* @param source 二维码图片
* @param logoPath LOGO图片地址
* @param needCompress 是否压缩
* @throws Exception
*/
private static void insertImage(int size, BufferedImage source, String logoPath, boolean needCompress) throws Exception {
int logoWidth = size / 5; //设置logo图片宽度为二维码图片的五分之一
int logoHeight = size / 5; //设置logo图片高度为二维码图片的五分之一
Image src = ImageIO.read(new URL(logoPath));
int width = src.getWidth(null);
int height = src.getHeight(null);
if (needCompress) { // 压缩LOGO
if (width > logoWidth) {
width = logoWidth;
}
if (height > logoHeight) {
height = logoHeight;
}
Image image = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
BufferedImage tag = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
g.dispose();
src = image;
}
// 插入LOGO
Graphics2D graph = source.createGraphics();
int x = (size - width) / 2;
int y = (size - height) / 2;
graph.drawImage(src, x, y, width, height, null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graph.setStroke(new BasicStroke(3f));
graph.draw(shape);
graph.dispose();
}
示例7: renderLexiconMarker
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
private void renderLexiconMarker(ViwnNodeSynset node, Point2D.Float pos,
GraphicsDecorator g) {
Shape lexicon = new Area(new RoundRectangle2D.Float(pos.x - 40, pos.y - 17, 23, 10, 12.5f, 5));
g.setColor(ViwnNodeSynset.PosBgColors.get(node.getPos()));
g.fillRoundRect(Math.round(pos.x - 40), Math.round(pos.y - 17), 23, 10, 12, 5);
g.setColor(Color.black);
g.draw(lexicon);
Font smallFont = new Font("Tahoma", Font.BOLD, 6);
g.setFont(smallFont);
g.drawString(node.getLexiconLabel(), pos.x - 38, pos.y - 10);
}
示例8: paintBorder
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* Paints the border for the specified component with the
* specified position and size.
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if ((this.thickness > 0) && (g instanceof Graphics2D)) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
Shape outer;
Shape inner;
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
outer = new Rectangle2D.Float(x, y, width, height);
inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
}
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);
}
}
示例9: insertImage
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
private static void insertImage(BufferedImage source, String imgPath,
boolean needCompress) throws Exception {
File file = new File(imgPath);
if (!file.exists()) {
System.err.println(""+imgPath+" 该文件不存在!");
return;
}
Image src = ImageIO.read(new File(imgPath));
int width = src.getWidth(null);
int height = src.getHeight(null);
if (needCompress) {// 压缩LOGO
if (width > WIDTH) {
width = WIDTH;
}
if (height > HEIGHT) {
height = HEIGHT;
}
Image image = src.getScaledInstance(width, height,
Image.SCALE_SMOOTH);
BufferedImage tag = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
g.dispose();
src = image;
}
// 插入LOGO
Graphics2D graph = source.createGraphics();
int x = (QRCODE_SIZE - width) / 2;
int y = (QRCODE_SIZE - height) / 2;
graph.drawImage(src, x, y, width, height, null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graph.setStroke(new BasicStroke(3f));
graph.draw(shape);
graph.dispose();
}
示例10: insertImage
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
private static void insertImage(BufferedImage source, String imgPath,
boolean needCompress) throws Exception {
File file = new File(imgPath);
if (!file.exists()) {
System.err.println(""+imgPath+" 该文件不存在!");
return;
}
Image src = ImageIO.read(new File(imgPath));
int width = src.getWidth(null);
int height = src.getHeight(null);
if (needCompress) { // 压缩LOGO
if (width > WIDTH) {
width = WIDTH;
}
if (height > HEIGHT) {
height = HEIGHT;
}
Image image = src.getScaledInstance(width, height,
Image.SCALE_SMOOTH);
BufferedImage tag = new BufferedImage(width, height,
BufferedImage.TYPE_INT_RGB);
Graphics g = tag.getGraphics();
g.drawImage(image, 0, 0, null); // 绘制缩小后的图
g.dispose();
src = image;
}
// 插入LOGO
Graphics2D graph = source.createGraphics();
int x = (QRCODE_SIZE - width) / 2;
int y = (QRCODE_SIZE - height) / 2;
graph.drawImage(src, x, y, width, height, null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graph.setStroke(new BasicStroke(3f));
graph.draw(shape);
graph.dispose();
}
示例11: paintBorder
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* Paints the border for the specified component with the
* specified position and size.
*
* @param c the component for which this border is being painted
* @param g the paint graphics
* @param x the x position of the painted border
* @param y the y position of the painted border
* @param width the width of the painted border
* @param height the height of the painted border
*/
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
if ((this.thickness > 0) && (g instanceof Graphics2D)) {
Graphics2D g2d = (Graphics2D) g;
Color oldColor = g2d.getColor();
g2d.setColor(this.lineColor);
Shape outer;
Shape inner;
int offs = this.thickness;
int size = offs + offs;
if (this.roundedCorners) {
float arc = .2f * offs;
outer = new RoundRectangle2D.Float(x, y, width, height, offs, offs);
inner = new RoundRectangle2D.Float(x + offs, y + offs, width - size, height - size, arc, arc);
}
else {
outer = new Rectangle2D.Float(x, y, width, height);
inner = new Rectangle2D.Float(x + offs, y + offs, width - size, height - size);
}
Path2D path = new Path2D.Float(Path2D.WIND_EVEN_ODD);
path.append(outer, false);
path.append(inner, false);
g2d.fill(path);
g2d.setColor(oldColor);
}
}
示例12: getRegiao
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
if (Regiao == null) {
Regiao = new RoundRectangle2D.Float(getLeft(), getTop(), getWidth(), getHeight(), getWidth()/3, getHeight());
}
return Regiao;
}
示例13: getRegiao
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
if (Regiao == null) {
Regiao = new RoundRectangle2D.Float(getLeft(), getTop(), getWidth(), getHeight(), distSelecao * 8, distSelecao * 8);
}
return Regiao;
}
示例14: getRegiao
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
@Override
public Shape getRegiao() {
if (Regiao == null) {
Regiao = new RoundRectangle2D.Float(getLeft(), getTop(), getWidth(), getHeight(), getWidth() / 3, getHeight());
}
return Regiao;
}
示例15: insertImage
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
private static void insertImage(BufferedImage source, String imgPath, boolean needCompress) throws Exception {
File file = new File(imgPath);
if (!file.exists()) {
System.err.println("" + imgPath + " ���ļ������ڣ�");
return;
}
Image src = ImageIO.read(new File(imgPath));
int width = src.getWidth(null);
int height = src.getHeight(null);
if (needCompress) { // ѹ��LOGO
if (width > WIDTH) {
width = WIDTH;
}
if (height > HEIGHT) {
height = HEIGHT;
}
src = src.getScaledInstance(width, height, Image.SCALE_SMOOTH);
}
// ����LOGO
Graphics2D graph = source.createGraphics();
int x = (QRCODE_SIZE - width) / 2;
int y = (QRCODE_SIZE - height) / 2;
graph.drawImage(src, x, y, width, height, null);
Shape shape = new RoundRectangle2D.Float(x, y, width, width, 6, 6);
graph.setStroke(new BasicStroke(3f));
graph.draw(shape);
graph.dispose();
}