本文整理匯總了Java中java.awt.BasicStroke類的典型用法代碼示例。如果您正苦於以下問題:Java BasicStroke類的具體用法?Java BasicStroke怎麽用?Java BasicStroke使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BasicStroke類屬於java.awt包,在下文中一共展示了BasicStroke類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: main
import java.awt.BasicStroke; //導入依賴的package包/類
public static void main(String[] argv) throws Exception {
BufferedImage im = getWhiteImage(30, 30);
Graphics2D g2 = (Graphics2D)im.getGraphics();
g2.setRenderingHint(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON);
g2.setRenderingHint(KEY_STROKE_CONTROL, VALUE_STROKE_PURE);
g2.setStroke(new BasicStroke(10, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL));
g2.setBackground(Color.white);
g2.setColor(Color.black);
Path2D p = getPath(0, 0, 20);
g2.draw(p);
if (!(new Color(im.getRGB(20, 19))).equals(Color.black)) {
throw new Exception("This pixel should be black");
}
}
示例2: DialValueIndicator
import java.awt.BasicStroke; //導入依賴的package包/類
/**
* Creates a new instance of <code>DialValueIndicator</code>.
*
* @param datasetIndex the dataset index.
* @param label the label.
*/
public DialValueIndicator(int datasetIndex, String label) {
this.datasetIndex = datasetIndex;
this.angle = -90.0;
this.radius = 0.3;
this.frameAnchor = RectangleAnchor.CENTER;
this.templateValue = new Double(100.0);
this.formatter = new DecimalFormat("0.0");
this.font = new Font("Dialog", Font.BOLD, 14);
this.paint = Color.black;
this.backgroundPaint = Color.white;
this.outlineStroke = new BasicStroke(1.0f);
this.outlinePaint = Color.blue;
this.insets = new RectangleInsets(4, 4, 4, 4);
this.valueAnchor = RectangleAnchor.RIGHT;
this.textAnchor = TextAnchor.CENTER_RIGHT;
}
示例3: strokeTo
import java.awt.BasicStroke; //導入依賴的package包/類
public void strokeTo(Shape src,
AffineTransform at,
BasicStroke bs,
boolean thin,
boolean normalize,
boolean antialias,
PathConsumer2D consumer)
{
System.out.println(name+".strokeTo("+
src.getClass().getName()+", "+
at+", "+
bs+", "+
(thin ? "thin" : "wide")+", "+
(normalize ? "normalized" : "pure")+", "+
(antialias ? "AA" : "non-AA")+", "+
consumer.getClass().getName()+")");
target.strokeTo(src, at, bs, thin, normalize, antialias, consumer);
}
示例4: redrawCanvas
import java.awt.BasicStroke; //導入依賴的package包/類
public void redrawCanvas(int x, int y, double a){
int R = (int)a;
int G =(int) (255-a);
int B = 0;
Graphics2D g= ((Graphics2D) canvas.getGraphics());
g.setColor(new Color(R,G,B));
g.setStroke(new BasicStroke(15));
g.drawLine(x, y,x, y);
g.dispose();
//((Graphics2D) canvas.getGraphics()).setStroke(new BasicStroke(30));
// ((Graphics2D) canvas.getGraphics()).drawLine(x, y,x, y);
// Graphics2D g2 = (Graphics2D) canvas.getGraphics();
// g2.setStroke(new BasicStroke(10));
// g2.draw(new Line2D.Double(x, y, x, y));
// canvas.paint(g2);
}
示例5: getStrokeSpans
import java.awt.BasicStroke; //導入依賴的package包/類
public static ShapeSpanIterator getStrokeSpans(SunGraphics2D sg2d,
Shape s)
{
ShapeSpanIterator sr = new ShapeSpanIterator(false);
try {
sr.setOutputArea(sg2d.getCompClip());
sr.setRule(PathIterator.WIND_NON_ZERO);
BasicStroke bs = (BasicStroke) sg2d.stroke;
boolean thin = (sg2d.strokeState <= SunGraphics2D.STROKE_THINDASHED);
boolean normalize =
(sg2d.strokeHint != SunHints.INTVAL_STROKE_PURE);
RenderEngine.strokeTo(s,
sg2d.transform, bs,
thin, normalize, false, sr);
} catch (Throwable t) {
sr.dispose();
sr = null;
throw new InternalError("Unable to Stroke shape ("+
t.getMessage()+")", t);
}
return sr;
}
示例6: scatterGridPlot
import java.awt.BasicStroke; //導入依賴的package包/類
public JFreeChart scatterGridPlot(String xLabel, String yLabel){
int numDatasets = dataset.size();
JFreeChart result = ChartFactory.createScatterPlot(chartTitle
, xLabel
, yLabel
, dataset.get(0));
XYPlot plot = result.getXYPlot();
plot.getRenderer().setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer().setSeriesPaint(0, seriesColor.get(0));
for(int i=1;i<numDatasets;i++){
plot.setDataset(i,dataset.get(i));
//XYItemRenderer renderer = plot.getRenderer(i-0);
plot.setRenderer(i, new XYLineAndShapeRenderer(true, true));
plot.getRenderer(i).setSeriesStroke(0, new BasicStroke(1.0f));
plot.getRenderer(i).setSeriesPaint(0,seriesColor.get(i));
}
return result;
}
開發者ID:PacktPublishing,項目名稱:Neural-Network-Programming-with-Java-SecondEdition,代碼行數:20,代碼來源:Chart.java
示例7: testPut
import java.awt.BasicStroke; //導入依賴的package包/類
/**
* Some checks for the put() method.
*/
public void testPut() {
StrokeMap m1 = new StrokeMap();
m1.put("A", new BasicStroke(1.1f));
assertEquals(new BasicStroke(1.1f), m1.getStroke("A"));
// a null key should throw an IllegalArgumentException
boolean pass = false;
try {
m1.put(null, new BasicStroke(1.1f));
}
catch (IllegalArgumentException e) {
pass = true;
}
assertTrue(pass);
}
示例8: createStroke
import java.awt.BasicStroke; //導入依賴的package包/類
/**
*
*/
public Stroke createStroke(Map<String, Object> style)
{
double width = mxUtils
.getFloat(style, mxConstants.STYLE_STROKEWIDTH, 1) * scale;
boolean dashed = mxUtils.isTrue(style, mxConstants.STYLE_DASHED);
if (dashed)
{
float[] dashPattern = mxUtils.getFloatArray(style,
mxConstants.STYLE_DASH_PATTERN,
mxConstants.DEFAULT_DASHED_PATTERN, " ");
float[] scaledDashPattern = new float[dashPattern.length];
for (int i = 0; i < dashPattern.length; i++)
{
scaledDashPattern[i] = (float) (dashPattern[i] * scale * width);
}
return new BasicStroke((float) width, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, 10.0f, scaledDashPattern, 0.0f);
}
else
{
return new BasicStroke((float) width);
}
}
示例9: doDrawShoulders
import java.awt.BasicStroke; //導入依賴的package包/類
final private void doDrawShoulders() {
// Set graphics :
final Graphics2D objLjugglerGraphics2D =
(Graphics2D) (Tools.contains( this.objGjuggleMasterPro.bytGjugglerVisibility,
Constants.bytS_BIT_VISIBILITY_TRAIL)
? this.imgGjugglerFrontTrailsBuffer.getGraphics()
: this.imgGanimationBuffer.getGraphics());
objLjugglerGraphics2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
this.doOptimizeGraphics(objLjugglerGraphics2D);
// Draw shoulders :
objLjugglerGraphics2D.setColor(this.objGjuggleMasterPro.objGjugglerColorA[this.objGjuggleMasterPro.bytGlight]);
for (byte bytLside = Constants.bytS_ENGINE_LEFT_SIDE; bytLside <= Constants.bytS_ENGINE_RIGHT_SIDE; ++bytLside) {
if (this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmVisible) {
objLjugglerGraphics2D.setStroke(new BasicStroke(this.objGjuggleMasterPro.objGstyleA[Constants.bytS_UNCLASS_CURRENT].getArmWidth(this.objGjuggleMasterPro.objGhandA[bytLside].fltGposZ,
(byte) 2,
this.objGjuggleMasterPro.objGhandA[bytLside].bolGarmHandZOrder),
BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND));
this.objGjuggleMasterPro.objGbody.drawArmPart(objLjugglerGraphics2D, this.fltGframeSizeRatio, bytLside, (byte) 2);
}
}
objLjugglerGraphics2D.dispose();
}
示例10: drawPoint
import java.awt.BasicStroke; //導入依賴的package包/類
/**
* 隨機畫點
*
* @param image 圖片
*/
private void drawPoint(BufferedImage image) {
if (this.pointPower == -1) {
return;
}
Random r = new Random();
Graphics2D g2 = (Graphics2D) image.getGraphics();
int max = this.w * this.h / this.pointPower;
for (int i = 0; i < max; i++) {
int x = r.nextInt(w);
int y = r.nextInt(h);
g2.setStroke(new BasicStroke(1.5F));
g2.setColor(this.randomColor());
g2.drawOval(x, y, 1, 1);
}
g2.dispose();
}
示例11: paintComponent
import java.awt.BasicStroke; //導入依賴的package包/類
@Override
public void paintComponent(Graphics g) {
SwingUtilities.invokeLater(() -> {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) getGraphics();
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
g2.setColor(Color.red);
g2.drawLine(pressed.x, pressed.y, released.x, released.y);
g2.setStroke(new BasicStroke(5, BasicStroke.JOIN_ROUND, BasicStroke.CAP_ROUND));
g2.drawOval(released.x - 25, released.y - 25, 50, 50);
g2.fillOval(released.x - 10, released.y - 10, 20, 20);
g2.dispose();
});
}
示例12: draw
import java.awt.BasicStroke; //導入依賴的package包/類
/**
* Draws the range.
*
* @param g2 the graphics target.
* @param plot the plot.
* @param frame the dial's reference frame (in Java2D space).
* @param view the dial's view rectangle (in Java2D space).
*/
public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame,
Rectangle2D view) {
Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame,
this.innerRadius, this.innerRadius);
Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame,
this.outerRadius, this.outerRadius);
//double range = this.upperBound - this.lowerBound;
DialScale scale = plot.getScaleForDataset(0);
double angleMin = scale.valueToAngle(this.lowerBound);
double angleMax = scale.valueToAngle(this.upperBound);
Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin,
angleMax - angleMin, Arc2D.OPEN);
Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax,
angleMin - angleMax, Arc2D.OPEN);
g2.setPaint(this.paint);
g2.setStroke(new BasicStroke(2.0f));
g2.draw(arcInner);
g2.draw(arcOuter);
}
示例13: FlyingToolTip
import java.awt.BasicStroke; //導入依賴的package包/類
public FlyingToolTip(final FlyingToolTipListener source) {
this.source = source;
label = new JLabel("test", JLabel.CENTER) {
@Override
public void paintComponent(Graphics g) {
Graphics2D g2 = (Graphics2D) g.create();
int w = getWidth(), h = getHeight();
g.setColor(getBackground());
g.fillRect(0,0,w,h);
if (path != null) {
g2.setStroke(new BasicStroke(4f));
g2.setColor(getForeground());
g2.draw(path);
}
setOpaque(false);
super.paintComponent(g2);
setOpaque(true);
g2.dispose();
}
};
label.setBorder(new EmptyBorder(2,4,10,4));
label.setOpaque(true);
}
示例14: DiscreteXYPainter
import java.awt.BasicStroke; //導入依賴的package包/類
DiscreteXYPainter(float lineWidth, Color lineColor, Color fillColor,
int width, boolean fixedWidth, boolean topLineOnly,
boolean outlineOnly, double dataFactor, PointsComputer computer) {
super((int)Math.ceil(lineWidth), fillColor != null ||
(!topLineOnly && !outlineOnly), dataFactor);
if (lineColor == null && fillColor == null)
throw new IllegalArgumentException("lineColor or fillColor must not be null"); // NOI18N
this.lineWidth = (int)Math.ceil(lineWidth);
this.lineColor = Utils.checkedColor(lineColor);
this.fillColor = Utils.checkedColor(fillColor);
definingColor = lineColor != null ? lineColor : fillColor;
this.lineStroke = new BasicStroke(lineWidth, BasicStroke.CAP_ROUND,
BasicStroke.JOIN_ROUND);
this.width = width;
this.fixedWidth = fixedWidth;
this.topLineOnly = topLineOnly;
this.outlineOnly = outlineOnly;
this.computer = computer;
}
示例15: drawCurrentPoint
import java.awt.BasicStroke; //導入依賴的package包/類
public void drawCurrentPoint() {
if( map==null || point==null || !map.isVisible() ) return;
synchronized (map.getTreeLock() ) {
Graphics2D g = map.getGraphics2D();
float zoom = (float)map.getZoom();
g.setStroke( new BasicStroke( 2f/ zoom ) );
g.setColor(Color.RED);
g.setXORMode( Color.white );
Rectangle2D rect = map.getClipRect2D();
double wrap = map.getWrap();
if( wrap>0. ) while( point.x-wrap > rect.getX() ) point.x-=wrap;
double size = 10./map.getZoom();
Arc2D.Double arc = new Arc2D.Double( 0., point.y-.5*size,
size, size, 0., 360., Arc2D.CHORD);
if( wrap>0. ) {
while( point.x < rect.getX()+rect.getWidth() ) {
arc.x = point.x-.5*size;
g.draw(arc);
point.x += wrap;
}
} else {
arc.x = point.x-.5*size;
g.draw(arc);
}
}
}