List of usage examples for com.google.gwt.canvas.dom.client CssColor make
public static final native CssColor make(String cssColor) ;
From source file:anagram.client.Ball.java
License:Apache License
public Ball(double x, double y, double z, double radius, String color) { this(new Vector(x, y), z, radius, CssColor.make(color)); }
From source file:co.fxl.gui.canvas.gwt.GWTCanvas.java
License:Open Source License
CssColor getColor(int[] rgb, double opacity) { String cssColor = "rgba(" + rgb[0] + "," + rgb[1] + "," + rgb[2] + "," + opacity + ")"; return CssColor.make(cssColor); }
From source file:com.akjava.gwt.volumegraph.client.VolumeGraph.java
License:Apache License
@Override protected void init(TestPreference preferences) { Hangout.setInjectHangoutService(injector.getHangoutService()); StyleInjector.inject(".grey{color:#666}"); HorizontalPanel root = new HorizontalPanel(); root.setSize("100%", "100%"); RootPanel.get().add(root);/*from w ww .j av a 2 s . c om*/ VerticalPanel mainPanel = new VerticalPanel(); mainPanel.setSize("100%", "100%"); HorizontalPanel controler = new HorizontalPanel(); mainPanel.add(controler); Label label = new Label("Emulate Participant"); label.setStylePrimaryName("grey"); controler.add(label); Button plus = new Button("+"); plus.setStylePrimaryName("grey"); controler.add(plus); plus.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { dummyParticipant++; } }); Button clear = new Button("remove"); clear.setStylePrimaryName("grey"); controler.add(clear); clear.addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { dummyParticipant = 0; } }); root.add(mainPanel); canvas = Canvas.createIfSupported(); canvas.setSize("100%", "400px"); canvas.getContext2d().setFillStyle(CssColor.make("#fff")); mainPanel.add(canvas); int w = canvas.getOffsetWidth(); int h = canvas.getOffsetHeight(); canvas.setCoordinateSpaceWidth(w); canvas.setCoordinateSpaceHeight(h); addReady(); }
From source file:com.google.gwt.maeglin89273.shared.test.volcanogame.component.FireBall.java
public FireBall(Spacial space, Point p, int radius) { super(new Point(p.getX(), p.getY() - radius), radius * 2, radius * 2); this.radius = radius; double h = 5 + Random.nextInt(21); double s = 80 + Random.nextInt(21); double l = 35 + Random.nextInt(16); ballColor = CssColor.make("hsl(" + h + "," + s + "%," + l + "%)"); ballShadowColor = CssColor.make("hsl(" + h + "," + s + "%," + (l + 15) + "%)"); this.space = space; aabb = new PixelAABB(this.position, width, height); BodyDef bodyDef = new BodyDef(); CircleShape shape = new CircleShape(); FixtureDef fixtureDef = new FixtureDef(); Vec2 impulse = CoordinateConverter/*from w w w .j a va 2 s . c o m*/ .vectorPixelsToWorld(new Vector(-30 + 60 * Random.nextDouble(), -(175 + 50 * Random.nextDouble()))); bodyDef.type = BodyType.DYNAMIC; bodyDef.position.set(CoordinateConverter.coordPixelsToWorld(position)); body = space.getWorld().createBody(bodyDef); body.setLinearVelocity(impulse); body.applyLinearImpulse(impulse, body.getPosition()); shape.m_radius = CoordinateConverter.scalerPixelsToWorld(radius); fixtureDef.shape = shape; fixtureDef.density = 4.3f; fixtureDef.restitution = 0.2f; fixtureDef.friction = 0.8f; body.createFixture(fixtureDef); }
From source file:com.google.gwt.sample.guestbook.client.CanvasOrbital.java
@Override public void init() { context.closePath();//from w w w . j a v a2s . c om context.beginPath(); context.clearRect(0, 0, WIDTH, HEIGHT); for (Mass body : bodies = orbital.getBodies()) { context.setFillStyle(CssColor.make("red")); context.fillRect(body.x, body.y, 3, 3); context.stroke(); } orbital.getOrbiterLocation(coord); context.moveTo(x = (int) coord[0], y = (int) coord[1]); // context.closePath(); }
From source file:com.google.gwt.sample.guestbook.client.CanvasOrbital.java
@Override public void numberOfBodiesChanged(Mass[] bodies) { for (Mass body : this.bodies) { context.setFillStyle(backgoundColour); context.fillRect(body.x, body.y, 3, 3); context.stroke();//ww w . j a v a 2 s . co m } for (Mass body : this.bodies = bodies) { context.setFillStyle(CssColor.make("red")); context.fillRect(body.x, body.y, 3, 3); context.stroke(); } }
From source file:com.himamis.retex.renderer.web.graphics.ColorW.java
License:Open Source License
public ColorW(String cssColorString) { cssColor = CssColor.make(cssColorString); }
From source file:com.imaginedreal.mgwt.trafficflow.client.activities.seattle.SeattleViewGwtImpl.java
License:Apache License
@Override public void renderFlowMap(final Map<String, StationItem> stationItems) { // canvas size in px final int width = 1121; final int height = 2585; // get the 2D rendering context context2 = flowCanvas.getContext2d(); // initialize the canvas flowCanvas.setWidth(width + "px"); flowCanvas.setHeight(height + "px"); flowCanvas.setPixelSize(width, height); flowCanvas.setCoordinateSpaceWidth(width); flowCanvas.setCoordinateSpaceHeight(height); for (Map.Entry<String, StationItem> entry : stationItems.entrySet()) { String[] values = entry.getValue().getXY().split(";"); context2.beginPath();//w w w . j a va 2 s.com for (int i = 1; i < values.length; i++) { String[] coords = values[i].split(","); if (i == 1) { context2.moveTo(Double.valueOf(coords[0]) + 0.5, Double.valueOf(coords[1]) + 0.5); } else { context2.lineTo(Double.valueOf(coords[0]) + 0.5, Double.valueOf(coords[1]) + 0.5); } } String cssColor = getColorStyle(entry.getValue().getSpeed()); context2.closePath(); context2.setFillStyle(CssColor.make(cssColor)); context2.fill(); context2.setStrokeStyle(CssColor.make(cssColor)); context2.setLineWidth(1); context2.setLineCap(LineCap.SQUARE); context2.setLineJoin(LineJoin.BEVEL); context2.stroke(); } }
From source file:com.imaginedreal.mgwt.trafficflow.client.activities.tacoma.TacomaViewGwtImpl.java
License:Apache License
@Override public void renderFlowMap(final Map<String, StationItem> stationItems) { // canvas size in px final int width = 1360; final int height = 1204; // get the 2D rendering context context2 = flowCanvas.getContext2d(); // initialize the canvas flowCanvas.setWidth(width + "px"); flowCanvas.setHeight(height + "px"); flowCanvas.setPixelSize(width, height); flowCanvas.setCoordinateSpaceWidth(width); flowCanvas.setCoordinateSpaceHeight(height); for (Map.Entry<String, StationItem> entry : stationItems.entrySet()) { String[] values = entry.getValue().getXY().split(";"); context2.beginPath();// w ww . java 2 s. c om for (int i = 1; i < values.length; i++) { String[] coords = values[i].split(","); if (i == 1) { context2.moveTo(Double.valueOf(coords[0]) + 0.5, Double.valueOf(coords[1]) + 0.5); } else { context2.lineTo(Double.valueOf(coords[0]) + 0.5, Double.valueOf(coords[1]) + 0.5); } } String cssColor = getColorStyle(entry.getValue().getSpeed()); context2.closePath(); context2.setFillStyle(CssColor.make(cssColor)); context2.fill(); context2.setStrokeStyle(CssColor.make(cssColor)); context2.setLineWidth(1); context2.setLineCap(LineCap.SQUARE); context2.setLineJoin(LineJoin.BEVEL); context2.stroke(); } }
From source file:com.mecatran.otp.gwt.client.view.ItineraryDetailsWidget.java
License:Open Source License
/** * Build the background image for the widget, according to the mode. Draw * the mode image and a solid line below it with the route color (if in * transit mode) or a dotted line (if in road mode). Set the * background-image to the generated image for the given widget. */// w w w. j ava2 s .co m public static void styleComponentWithMode(final Widget widget, TransportMode mode, String color) { PlannerResources resources = PlannerResources.INSTANCE; ImageResource baseImage = null; boolean road = false; switch (mode) { case WALK: road = true; color = "#666666"; baseImage = resources.modeWalkPng(); break; case BICYCLE: road = true; color = "#23C30B"; baseImage = resources.modeBicyclePng(); break; case BICYCLE_RENTAL: road = true; color = "#23C30B"; baseImage = resources.modeBikeRentalPng(); break; case CAR: road = true; color = "#333333"; baseImage = resources.modeCarPng(); break; default: case BUS: baseImage = resources.modeBusPng(); break; case TRAM: baseImage = resources.modeTramPng(); break; case FERRY: baseImage = resources.modeFerryPng(); break; case GONDOLA: baseImage = resources.modeGondolaPng(); break; case PLANE: baseImage = resources.modePlanePng(); break; case RAIL: baseImage = resources.modeRailPng(); break; case SUBWAY: baseImage = resources.modeSubwayPng(); break; case TROLLEY: baseImage = resources.modeTrolleyPng(); break; } final String url = baseImage.getSafeUri().asString(); final Canvas canvas = Canvas.createIfSupported(); if (canvas != null) { int width = baseImage.getWidth(); int height = 1000; canvas.setCoordinateSpaceWidth(width); canvas.setCoordinateSpaceHeight(height); final Context2d context = canvas.getContext2d(); context.setLineCap(LineCap.BUTT); if (road) { context.setStrokeStyle(CssColor.make(color)); context.setLineWidth(4); for (int y = baseImage.getHeight(); y < 1000; y += 7) { context.moveTo(width / 2, y); context.lineTo(width / 2, y + 5); } context.stroke(); } else { context.setStrokeStyle(CssColor.make("#000000")); context.setLineWidth(5); context.moveTo(width / 2, 0); context.lineTo(width / 2, height - 1); context.stroke(); context.setStrokeStyle(CssColor.make(color)); context.setLineWidth(4); context.moveTo(width / 2, 0); context.lineTo(width / 2, height - 1); context.stroke(); } /* * HACK ALERT! Image.onLoad event does not fire up when using * internal resources (URL is internal data), but using the image * immediately does not work (image does not seems to be ready). We * defer the processing of the image rendering to a timer delayed a * bit. */ Timer timer = new Timer() { @Override public void run() { Image image = new Image(url); ImageElement e = ImageElement.as(image.getElement()); context.drawImage(e, 0, 0); String url2 = canvas.toDataUrl("image/png"); widget.getElement().getStyle().setBackgroundImage("url('" + url2 + "')"); } }; timer.schedule(500); } else { widget.getElement().getStyle().setBackgroundImage("url('" + url + "')"); } }