本文整理汇总了Java中java.awt.geom.RoundRectangle2D.setRoundRect方法的典型用法代码示例。如果您正苦于以下问题:Java RoundRectangle2D.setRoundRect方法的具体用法?Java RoundRectangle2D.setRoundRect怎么用?Java RoundRectangle2D.setRoundRect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.geom.RoundRectangle2D
的用法示例。
在下文中一共展示了RoundRectangle2D.setRoundRect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getRawShape
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape( VisualItem item )
{
m_text = getText( item );
double size = item.getSize();
// get text dimensions
int tw = 0, th = 0;
if ( m_text != null ) {
m_text = computeTextDimensions( item, m_text, size );
th = m_textDim.height;
tw = m_textDim.width;
}
// get bounding box dimensions
double w = tw, h = th;
// get the top-left point, using the current alignment settings
getAlignedPoint( m_pt, item, w, h, m_xAlign, m_yAlign );
if ( m_bbox instanceof RoundRectangle2D ) {
RoundRectangle2D rr = (RoundRectangle2D)m_bbox;
rr.setRoundRect(
m_pt.getX(), m_pt.getY(), w, h,
size * m_arcWidth, size * m_arcHeight
);
}
else {
m_bbox.setFrame( m_pt.getX(), m_pt.getY(), w, h );
}
return m_bbox;
}
示例2: paintComponent
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
@Override
protected void paintComponent(Graphics g0) {
super.paintComponent(g0);
Graphics2D g = (Graphics2D)g0.create();
Dimension navigationSize;
if(navigationPanel.getParent()==null) {
navigationSize = new Dimension(0,0);
} else {
navigationSize = navigationPanel.getSize();
navigationSize.height += navigationPadding;
}
double w = getWidth()-insets.left-insets.right;
double h = getHeight()-insets.top-insets.bottom-navigationSize.height;
double wRatio = w/paperRect.getWidth();
double hRatio = h/paperRect.getHeight();
double zoom = Math.min(wRatio,hRatio);
g.translate( (w+insets.left+insets.right)/2-paperRect.getWidth()*zoom/2,
center ? (h+insets.top+insets.bottom)/2-paperRect.getHeight()*zoom/2+navigationSize.height : 0);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
g.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
int shadowIterations = (int)(6*Math.pow(Math.min(getWidth(),getHeight())/200.0,.8));
if(shadowIterations==0) shadowIterations = 1;
g.setColor(new Color(0,0,0,50/shadowIterations));
double paperWidth = paperRect.getWidth()*zoom;
double paperHeight = paperRect.getHeight()*zoom;
RoundRectangle2D r = new RoundRectangle2D.Double();
for(int a = 0; a<shadowIterations; a++) {
r.setRoundRect(-a,-a/3,paperWidth+2*a+1,paperHeight+a+1,3*a,3*a);
g.fill(r);
}
g.scale(zoom, zoom);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g.setColor(Color.white);
g.fill(paperRect);
g.setColor(Color.darkGray);
g.draw(paperRect);
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// draw demo paintables
layoutPaintable.paint(g);
}
示例3: getRawShape
import java.awt.geom.RoundRectangle2D; //导入方法依赖的package包/类
/**
* @see prefuse.render.AbstractShapeRenderer#getRawShape(prefuse.visual.VisualItem)
*/
protected Shape getRawShape(VisualItem item) {
m_text = getText(item);
Image[] img = getImage(item);
double size = item.getSize();
// get text dimensions
int tw=0, th=0;
if ( m_text != null ) {
m_text = computeTextDimensions(item, m_text, size);
th = m_textDim.height;
tw = m_textDim.width;
}
// get image dimensions
double iw=0, ih=0;
for (Image i: img) {
if (i == null) {
continue;
}
ih = i.getHeight(null) * imgScale(i);
iw += i.getWidth(null) * imgScale(i) + 2;
}
// get bounding box dimensions
double w=0, h=0;
switch ( m_imagePos ) {
case Constants.LEFT:
case Constants.RIGHT:
w = tw + size*(iw +2*m_horizBorder
+ (tw>0 && iw>0 ? m_imageMargin : 0));
h = Math.max(th, size*ih) + size*2*m_vertBorder;
break;
case Constants.TOP:
case Constants.BOTTOM:
w = Math.max(tw, size*iw) + size*2*m_horizBorder;
h = th + size*(ih + 2*m_vertBorder
+ (th>0 && ih>0 ? m_imageMargin : 0));
break;
default:
throw new IllegalStateException(
"Unrecognized image alignment setting.");
}
// get the top-left point, using the current alignment settings
getAlignedPoint(m_pt, item, w, h, m_xAlign, m_yAlign);
if ( m_bbox instanceof RoundRectangle2D ) {
RoundRectangle2D rr = (RoundRectangle2D)m_bbox;
rr.setRoundRect(m_pt.getX(), m_pt.getY(), w, h,
size*m_arcWidth, size*m_arcHeight);
} else {
m_bbox.setFrame(m_pt.getX(), m_pt.getY(), w, h);
}
return m_bbox;
}