Java Code Examples for javafx.scene.canvas.GraphicsContext#fillOval()

The following examples show how to use javafx.scene.canvas.GraphicsContext#fillOval() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XnorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x + width * 0.1, y + height);
	graphics.arc(x + width * 0.1, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width, y + height * 1.3, width * 0.7);
	graphics.arcTo(x + width * 0.66, y + height, x + width * 0.1, y + height, width * 0.7);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.strokeArc(x - width * 0.3, y, width * 0.5, height, 270, 180, ArcType.OPEN);
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 2
Source File: DebugDrawJavaFX.java    From jbox2d with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void drawParticles(Vec2[] centers, float radius, ParticleColor[] colors, int count) {
  GraphicsContext g = getGraphics();
  saveState(g);
  double scaling = transformGraphics(g, zero) * radius;
  g.setLineWidth(stroke / scaling);
  for (int i = 0; i < count; i++) {
    Vec2 center = centers[i];
    Color color;
    if (colors == null) {
      color = pcolorA;
    } else {
      ParticleColor c = colors[i];
      color = cpool.getColor(c.r * 1f / 127, c.g * 1f / 127, c.b * 1f / 127, c.a * 1f / 127);
    }
    Affine old = g.getTransform();
    g.translate(center.x, center.y);
    g.scale(radius, radius);
    g.setFill(color);
    g.fillOval(circle.getMinX(), circle.getMinX(), circle.getWidth(), circle.getHeight());
    g.setTransform(old);
  }
  restoreState(g);
}
 
Example 3
Source File: DebugDrawJavaFX.java    From jbox2d with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void drawSolidCircle(Vec2 center, float radius, Vec2 axis, Color3f color) {
  GraphicsContext g = getGraphics();
  Color f = cpool.getColor(color.x, color.y, color.z, .4f);
  Color s = cpool.getColor(color.x, color.y, color.z, 1f);
  saveState(g);
  double scaling = transformGraphics(g, center) * radius;
  g.setLineWidth(stroke / scaling);
  g.scale(radius, radius);
  g.setFill(f);
  g.fillOval(circle.getMinX(), circle.getMinX(), circle.getWidth(), circle.getHeight());
  g.setStroke(s);
  g.strokeOval(circle.getMinX(), circle.getMinX(), circle.getWidth(), circle.getHeight());
  if (axis != null) {
    g.rotate(MathUtils.atan2(axis.y, axis.x));
    g.strokeLine(0, 0, 1, 0);
  }
  restoreState(g);
}
 
Example 4
Source File: AmpSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawLed(final GraphicsContext CTX) {
    CTX.clearRect(0, 0, ledSize, ledSize);
    CTX.setFill(frameGradient);
    CTX.fillOval(0, 0, ledSize, ledSize);

    CTX.save();
    if (gauge.isLedOn()) {
        CTX.setEffect(ledOnShadow);
        CTX.setFill(ledOnGradient);
    } else {
        CTX.setEffect(ledOffShadow);
        CTX.setFill(ledOffGradient);
    }
    CTX.fillOval(0.14 * ledSize, 0.14 * ledSize, 0.72 * ledSize, 0.72 * ledSize);
    CTX.restore();

    CTX.setFill(highlightGradient);
    CTX.fillOval(0.21 * ledSize, 0.21 * ledSize, 0.58 * ledSize, 0.58 * ledSize);
}
 
Example 5
Source File: PlainAmpSkin.java    From Medusa with Apache License 2.0 6 votes vote down vote up
private void drawLed(final GraphicsContext CTX) {
    CTX.clearRect(0, 0, ledSize, ledSize);
    CTX.setFill(frameGradient);
    CTX.fillOval(0, 0, ledSize, ledSize);

    CTX.save();
    if (gauge.isLedOn()) {
        CTX.setEffect(ledOnShadow);
        CTX.setFill(ledOnGradient);
    } else {
        CTX.setEffect(ledOffShadow);
        CTX.setFill(ledOffGradient);
    }
    CTX.fillOval(0.14 * ledSize, 0.14 * ledSize, 0.72 * ledSize, 0.72 * ledSize);
    CTX.restore();

    CTX.setFill(highlightGradient);
    CTX.fillOval(0.21 * ledSize, 0.21 * ledSize, 0.58 * ledSize, 0.58 * ledSize);
}
 
Example 6
Source File: FireworksSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void draw(GraphicsContext context) {
    final double x = Math.round(posX);
    final double y = Math.round(posY);
    final double xVel = (x - lastPosX) * -5;
    final double yVel = (y - lastPosY) * -5;
    // set the opacity for all drawing of this particle
    context.setGlobalAlpha(Math.random() * this.alpha);
    // draw particle
    context.setFill(color);
    context.fillOval(x-size, y-size, size+size, size+size);
    // draw the arrow triangle from where we were to where we are now
    if (hasTail) {
        context.setFill(Color.rgb(255,255,255,0.3));
        context.fillPolygon(new double[]{posX + 1.5,posX + xVel,posX - 1.5}, 
                new double[]{posY,posY + yVel,posY}, 3);
    }
}
 
Example 7
Source File: NandGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y);
	graphics.lineTo(x, y + height);
	graphics.arc(x + width * 0.3, y + height * 0.5, width * 0.5, height * 0.5, 270, 180);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 8
Source File: NorGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 4 * GuiUtils.BLOCK_SIZE;
	int height = 4 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y + height);
	graphics.arc(x, y + height * 0.5, width * 0.25, height * 0.5, 270, 180);
	graphics.arcTo(x + width * 0.66, y, x + width, y + height * 1.3, width * 0.7);
	graphics.arcTo(x + width * 0.66, y + height, x, y + height, width * 0.7);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
	graphics.strokeOval(x + width * 0.8, y + height * 0.5 - width * 0.1, width * 0.2, width * 0.2);
}
 
Example 9
Source File: NotGatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void paintGate(GraphicsContext graphics, CircuitState circuitState) {
	int x = getScreenX();
	int y = getScreenY();
	int width = 3 * GuiUtils.BLOCK_SIZE;
	int height = 2 * GuiUtils.BLOCK_SIZE;
	
	graphics.beginPath();
	graphics.moveTo(x, y);
	graphics.lineTo(x, y + height);
	graphics.lineTo(x + width * 0.7, y + height * 0.5);
	graphics.closePath();
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	graphics.fill();
	graphics.stroke();
	
	graphics.fillOval(x + width * 0.7, y + height * 0.5 - width * 0.125, width * 0.25, width * 0.25);
	graphics.strokeOval(x + width * 0.7, y + height * 0.5 - width * 0.125, width * 0.25, width * 0.25);
}
 
Example 10
Source File: CustomPlainAmpSkin.java    From medusademo with Apache License 2.0 6 votes vote down vote up
private void drawLed(final GraphicsContext CTX) {
    CTX.clearRect(0, 0, ledSize, ledSize);
    CTX.setFill(frameGradient);
    CTX.fillOval(0, 0, ledSize, ledSize);

    CTX.save();
    if (gauge.isLedOn()) {
        CTX.setEffect(ledOnShadow);
        CTX.setFill(ledOnGradient);
    } else {
        CTX.setEffect(ledOffShadow);
        CTX.setFill(ledOffGradient);
    }
    CTX.fillOval(0.14 * ledSize, 0.14 * ledSize, 0.72 * ledSize, 0.72 * ledSize);
    CTX.restore();

    CTX.setFill(highlightGradient);
    CTX.fillOval(0.21 * ledSize, 0.21 * ledSize, 0.58 * ledSize, 0.58 * ledSize);
}
 
Example 11
Source File: DemoHelper.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
public static void refresh(final Canvas canvas)
{
    final GraphicsContext gc = canvas.getGraphicsContext2D();

    final Bounds bounds = canvas.getBoundsInLocal();
    final double width = bounds.getWidth();
    final double height = bounds.getHeight();

    gc.clearRect(0, 0, width, height);
    gc.strokeRect(0, 0, width, height);

    for (int i=0; i<ITEMS; ++i)
    {
        gc.setFill(Color.hsb(Math.random()*360.0,
                             Math.random(),
                             Math.random()));
        final double size = 5 + Math.random() * 40;
        final double x = Math.random() * (width-size);
        final double y = Math.random() * (height-size);
        gc.fillOval(x, y, size, size);
    }
}
 
Example 12
Source File: FireworksSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public void draw(GraphicsContext context) {
    final double x = Math.round(posX);
    final double y = Math.round(posY);
    final double xVel = (x - lastPosX) * -5;
    final double yVel = (y - lastPosY) * -5;
    // set the opacity for all drawing of this particle
    context.setGlobalAlpha(Math.random() * this.alpha);
    // draw particle
    context.setFill(color);
    context.fillOval(x-size, y-size, size+size, size+size);
    // draw the arrow triangle from where we were to where we are now
    if (hasTail) {
        context.setFill(Color.rgb(255,255,255,0.3));
        context.fillPolygon(new double[]{posX + 1.5,posX + xVel,posX - 1.5}, 
                new double[]{posY,posY + yVel,posY}, 3);
    }
}
 
Example 13
Source File: SimpleLineChartSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void drawBullet(final GraphicsContext CTX, final double X, final double Y, final Paint COLOR) {
    double iconSize = 0.04 * size;
    CTX.save();
    CTX.setLineWidth(0.0125 * height);
    CTX.setStroke(getSkinnable().getSeriesStroke());
    CTX.setFill(COLOR);
    CTX.strokeOval(X - iconSize * 0.5, Y - iconSize * 0.5, iconSize, iconSize);
    CTX.fillOval(X - iconSize * 0.5, Y - iconSize * 0.5, iconSize, iconSize);
    CTX.restore();
}
 
Example 14
Source File: DFlipFlopPeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void paint(GraphicsContext graphics, CircuitState state) {
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	GuiUtils.drawShape(graphics::fillRect, this);
	GuiUtils.drawShape(graphics::strokeRect, this);
	
	int x = getScreenX();
	int y = getScreenY();
	int width = getScreenWidth();
	int height = getScreenHeight();
	
	State bit = state.getLastPushed(getComponent().getPort(DFlipFlop.PORT_Q)).getBit(0);
	GuiUtils.setBitColor(graphics, bit);
	graphics.fillOval(x + width * 0.5 - 10, y + height * 0.5 - 10, 20, 20);
	
	graphics.setFill(Color.WHITE);
	graphics.setFont(GuiUtils.getFont(16));
	graphics.fillText(String.valueOf(bit.repr), x + width * 0.5 - 5, y + height * 0.5 + 6);
	
	graphics.setFill(Color.GRAY);
	graphics.setFont(GuiUtils.getFont(10));
	graphics.fillText("D", x + 3, y + height - 7);
	graphics.fillText("Q", x + width - 10, y + 13);
	graphics.fillText("1", x + 7, y + height - 4);
	graphics.fillText("en", x + width * 0.5 - 6, y + height - 4);
	graphics.fillText("0", x + width - 13, y + height - 4);
	
	graphics.setStroke(Color.BLACK);
	GuiUtils.drawClockInput(graphics, clockConnection, Direction.WEST);
}
 
Example 15
Source File: GatePeer.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final void paint(GraphicsContext graphics, CircuitState circuitState) {
	graphics.setFill(Color.WHITE);
	graphics.setStroke(Color.BLACK);
	
	for(int i = 0; i < getConnections().size() - 1; i++) {
		if(getComponent().getNegateInputs()[i]) {
			PortConnection c = getConnections().get(i);
			int x = c.getX() * GuiUtils.BLOCK_SIZE;
			int y = c.getY() * GuiUtils.BLOCK_SIZE;
			
			switch(getProperties().getValue(Properties.DIRECTION)) {
				case WEST:
					x -= GuiUtils.BLOCK_SIZE;
				case EAST:
					y -= GuiUtils.BLOCK_SIZE * 0.5;
					break;
				case NORTH:
					y -= GuiUtils.BLOCK_SIZE;
				case SOUTH:
					x -= GuiUtils.BLOCK_SIZE * 0.5;
					break;
			}
			
			graphics.fillOval(x, y, GuiUtils.BLOCK_SIZE, GuiUtils.BLOCK_SIZE);
			graphics.strokeOval(x, y, GuiUtils.BLOCK_SIZE, GuiUtils.BLOCK_SIZE);
		}
	}
	
	GuiUtils.drawName(graphics, this, getProperties().getValue(Properties.LABEL_LOCATION));
	GuiUtils.rotateGraphics(this, graphics, getProperties().getValue(Properties.DIRECTION));
	
	if(hasNegatedInput) {
		graphics.translate(GuiUtils.BLOCK_SIZE, 0);
	}
	
	paintGate(graphics, circuitState);
}
 
Example 16
Source File: ParticlesClockApp.java    From FXTutorials with MIT License 5 votes vote down vote up
void render(GraphicsContext g) {
    Point2D center = new Point2D(350, 200);
    double alpha = 1 - new Point2D(x, y).distance(center) / 500;

    g.setGlobalAlpha(alpha);
    g.fillOval(x, y, 2, 2);
}
 
Example 17
Source File: DebugDrawJavaFX.java    From jbox2d with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public void drawPoint(Vec2 argPoint, float argRadiusOnScreen, Color3f argColor) {
  getWorldToScreenToOut(argPoint, sp1);
  GraphicsContext g = getGraphics();

  Color c = cpool.getColor(argColor.x, argColor.y, argColor.z);
  g.setStroke(c);
  sp1.x -= argRadiusOnScreen;
  sp1.y -= argRadiusOnScreen;
  g.fillOval((int) sp1.x, (int) sp1.y, (int) argRadiusOnScreen * 2, (int) argRadiusOnScreen * 2);
}
 
Example 18
Source File: Connection.java    From CircuitSim with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void paint(GraphicsContext graphics, CircuitState circuitState) {
	GuiUtils.setBitColor(graphics, circuitState, getLinkWires());
	graphics.fillOval(getScreenX(), getScreenY(), getScreenWidth(), getScreenHeight());
}
 
Example 19
Source File: Helper.java    From Medusa with Apache License 2.0 4 votes vote down vote up
public static final void drawDot(final GraphicsContext CTX, final double CENTER_X, final double CENTER_Y, final double SIZE) {
    CTX.fillOval(CENTER_X, CENTER_Y, SIZE, SIZE);
}
 
Example 20
Source File: Particle.java    From FXTutorials with MIT License 4 votes vote down vote up
public void draw(GraphicsContext g) {
    g.setFill(color);

    g.setGlobalAlpha(life);
    g.fillOval(getX(), getY(), 1, 1);
}