本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.setFillStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.setFillStyle方法的具體用法?Java Context2d.setFillStyle怎麽用?Java Context2d.setFillStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.setFillStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createBillboard
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public static BillboardOptions createBillboard(DrawInteractionOptions options) {
Canvas canvas = Canvas.createIfSupported();
Context2d context = canvas.getContext2d();
context.setFillStyle(options.color.toCssColorString());
context.setStrokeStyle(options.outlineColor.toCssColorString());
context.setLineWidth(options.outlineWidth);
context.translate(canvas.getCoordinateSpaceWidth() / 2, canvas.getCoordinateSpaceHeight() / 2);
context.beginPath();
context.arc(0, 0, options.pixelSize, 0, Math.PI * 2, true);
context.closePath();
context.stroke();
context.fill();
BillboardOptions billboard = new BillboardOptions();
billboard.horizontalOrigin = HorizontalOrigin.CENTER();
billboard.verticalOrigin = VerticalOrigin.CENTER();
billboard.imageCanvas = canvas.getCanvasElement();
return billboard;
}
示例2: prepareMissingTileImage
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private CanvasElement prepareMissingTileImage() {
int tileSize = DjvuContext.getTileSize();
CanvasElement canvas = createImage(tileSize, tileSize);
Context2d context2d = canvas.getContext2d();
context2d.setFillStyle("white");
context2d.fillRect(0, 0, canvas.getWidth(), canvas.getHeight());
Image image = new Image();
final ImageElement imageElement = image.getElement().cast();
imageElement.getStyle().setProperty("visibility", "hidden");
Event.setEventListener(imageElement, event -> {
if (Event.ONLOAD == event.getTypeInt()) {
missingTileImage.getContext2d().drawImage(imageElement, 0, 0);
RootPanel.get().getElement().removeChild(imageElement);
}
});
RootPanel.get().getElement().appendChild(imageElement);
image.setUrl(getBlankImageUrl());
return canvas;
}
示例3: setTile
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void setTile(TileInfo tileInfo, GMap bufferGMap) {
if (bufferImageData == null || bufferImageData.getWidth() != bufferGMap.getDataWidth()
|| bufferImageData.getHeight() != bufferGMap.getDataHeight()) {
bufferImageData = bufferCanvas.getContext2d()
.createImageData(bufferGMap.getDataWidth(), bufferGMap.getDataHeight());
}
Uint8Array imageArray = bufferImageData.getData().cast();
imageArray.set(bufferGMap.getImageData());
bufferCanvas.getContext2d().putImageData(bufferImageData, -bufferGMap.getBorder(), 0);
CanvasElement tile = tiles.get(tileInfo);
if (tile == null) {
tile = createImage(bufferGMap.getDataWidth() - bufferGMap.getBorder(), bufferGMap.getDataHeight());
tiles.put(new TileInfo(tileInfo), tile);
}
Context2d c = tile.getContext2d();
c.setFillStyle("white");
c.fillRect(0, 0, tileSize, tileSize);
c.drawImage(bufferCanvas, 0, 0);
for (Consumer<Integer> listener : tileListeners)
listener.accept(tileInfo.page);
}
示例4: sizeAndPaintCanvases
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void sizeAndPaintCanvases(final int canvasHeight, final int canvasWidth, final int barWidth) {
this.canvasHeight = canvasHeight;
this.canvasWidth = canvasWidth;
mainCanvas.setCoordinateSpaceHeight(canvasHeight);
mainCanvas.setCoordinateSpaceWidth(canvasWidth);
mainCanvas.setSize(canvasWidth + "px", canvasHeight + "px");
hueCanvas.setCoordinateSpaceHeight(canvasHeight);
hueCanvas.setCoordinateSpaceWidth(barWidth);
hueCanvas.setSize(barWidth + "px", canvasHeight + "px");
final Context2d hueContext2d = hueCanvas.getContext2d();
CanvasGradient hueGradient = hueContext2d.createLinearGradient(0, 0, 0, canvasHeight);
for (int stop = 0; stop <= 10; stop++) {
hueGradient.addColorStop(stop * 0.1f, "hsl(" + 36 * stop + ",100%,50%)");
}
hueContext2d.setFillStyle(hueGradient);
hueContext2d.fillRect(0, 0, barWidth, canvasHeight);
}
開發者ID:languageininteraction,項目名稱:GraphemeColourSynaesthesiaApp,代碼行數:19,代碼來源:ColourPickerCanvasView.java
示例5: setHue
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
synchronized private void setHue(String colourCss) {
currentHueCss = colourCss;
// " Android clearRect / fillRect bug" ???
// GWT documentation: JavaScript interpreters are single-threaded, so while GWT silently accepts the synchronized keyword, it has no real effect.
// So we are using a simple boolean which should be adequate most of the time. We could use a timer call back, but we want to keep this simple.
// However the browser is probably only single threaded anyway.
if (hueChangeInProgress) {
return;
}
hueChangeInProgress = true;
final Context2d mainContext2dA = mainCanvas.getContext2d();
CanvasGradient linearColour = mainContext2dA.createLinearGradient(0, 0, canvasWidth, 0);
linearColour.addColorStop(1f, "white");
linearColour.addColorStop(0f, colourCss);
mainContext2dA.setFillStyle(linearColour);
mainContext2dA.fillRect(0, 0, canvasWidth, canvasHeight);
// todo: remove the second context get if it proves unhelpful witht the samsung 4.2.2 issue
final Context2d mainContext2dB = mainCanvas.getContext2d();
CanvasGradient linearGrey = mainContext2dB.createLinearGradient(0, 0, 0, canvasHeight);
linearGrey.addColorStop(1f, "black");
linearGrey.addColorStop(0f, "rgba(0,0,0,0)");
mainContext2dB.setFillStyle(linearGrey);
mainContext2dB.fillRect(0, 0, canvasWidth, canvasHeight);
hueChangeInProgress = false;
}
開發者ID:languageininteraction,項目名稱:GraphemeColourSynaesthesiaApp,代碼行數:27,代碼來源:ColourPickerCanvasView.java
示例6: repaint
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void repaint(Tool tool, int x, int y, int tileSize){
Context2d context = canvasLayer.getContext();
context.clearRect(0, 0, canvasLayer.getWidth(), canvasLayer.getHeight());
if (tool == Tool.BRUSH) {
} else if (tool == Tool.ERASER) {
Eraser eraser = ToolBox.getInstance().getEraser();
int size = eraser.getSize()*tileSize;
context.save();
context.setLineWidth(1.0);
context.setStrokeStyle(CssColors.RED);
context.setFillStyle(CssColors.LIGHT_GREY);
context.rect(x, y, size, size);
context.stroke();
context.setGlobalAlpha(0.25);
context.fill();
context.restore();
}
}
示例7: drawTics
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void drawTics(int count, int len, long factor, String unit) {
Context2d context = canvas.getContext2d();
context.setFillStyle(color);
context.setStrokeStyle(color);
for (int i = 1; i <= count; i++) {
context.beginPath();
context.moveTo(len * i, 0);
context.lineTo(len * i, 15);
context.closePath();
context.stroke();
context.fillText((i * factor) + unit, len * i, 25, 20);
}
}
示例8: MultiLineTextDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public MultiLineTextDisplayElement(String id, int x, int y, int width, int height,
String text, String label, int[][] coords) {
super(id, x, y, width, height);
this.coords = coords;
this.label = label;
this.text = text;
popup = new PopupPanel(true, false);
HTML content = new HTML(text);
popup.setStylePrimaryName("PopupPanel");
popup.addStyleName("AnnotationPopup");
popup.setWidget(content);
// Create a canvas containing the filled polygon with no border
Canvas sub_canvas = Canvas.createIfSupported();
sub_canvas.setCoordinateSpaceWidth(width);
sub_canvas.setCoordinateSpaceHeight(height);
Context2d context = sub_canvas.getContext2d();
context.beginPath();
context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
}
context.setFillStyle(color_fill);
context.fill();
context.closePath();
this.image_data = context.getImageData(0, 0, width, height);
}
示例9: PolygonDisplayElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public PolygonDisplayElement(String id, int x, int y, int width,
int height, int[][] coords) {
super(id, x, y, width, height);
this.coords = coords;
// Create a canvas containing the filled polygon with no border
Canvas sub_canvas = Canvas.createIfSupported();
sub_canvas.setCoordinateSpaceWidth(baseWidth());
sub_canvas.setCoordinateSpaceHeight(baseHeight());
Context2d context = sub_canvas.getContext2d();
context.save();
context.beginPath();
context.moveTo(coords[0][0] - baseLeft(), coords[0][1] - baseTop());
for (int i = 1; i < coords.length; i++) {
context.lineTo(coords[i][0] - baseLeft(), coords[i][1] - baseTop());
}
context.setFillStyle(fill_color);
context.fill();
context.closePath();
context.restore();
this.image_data = context.getImageData(0, 0, baseWidth(), baseHeight());
}
示例10: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
if (!isVisible()) {
return;
}
redrawNeeded = false;
g.save();
g.translate(x, y);
if (redrawBufferNeeded) {
buffer.render();
redrawBufferNeeded = false;
}
if (null != backgroundColor) {
g.beginPath();
g.rect(0, 0, width, height);
g.setFillStyle(backgroundColor);
g.fill();
}
buffer.flip(g);
g.restore();
}
示例11: onBeforeDraw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public boolean onBeforeDraw(AbstractChart<?, ?> chart, double easing, JavaScriptObject options) {
// creates the plugin options using the java script object
// passing also the default color set at constructor.
ChartBackgroundColorOptions bgOptions = new ChartBackgroundColorOptions(options, color);
// gets the canvas
Context2d ctx = chart.getCanvas().getContext2d();
// set fill canvas color
ctx.setFillStyle(bgOptions.getBackgroundColor());
// fills back ground
ctx.fillRect(0, 0, chart.getCanvas().getWidth(), chart.getCanvas().getHeight());
// always TRUE
return true;
}
示例12: getImage
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private CanvasElement getImage() {
if (!Cesium.defined(particleCanvas)) {
particleCanvas = RootPanel.get().getElement().getOwnerDocument().createCanvasElement();
particleCanvas.setWidth(20);
particleCanvas.setHeight(20);
Context2d context2d = particleCanvas.getContext2d();
context2d.beginPath();
context2d.arc(8, 8, 8, 0, Math.TWO_PI(), true);
context2d.closePath();
context2d.setFillStyle("rgb(255, 255, 255)");
context2d.fill();
Cesium.log(particleCanvas);
}
return particleCanvas;
}
示例13: paint
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void paint( JsonDistribution d, Context2d g, int x, int y, int w, int h ) {
for( int i = 0; i < bars.length; i++ ) {
Rectangle r = bars[i];
g.setFillStyle( colors[i] );
g.fillRect( r.x, r.y, r.w, r.h );
}
}
示例14: setStyle
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void setStyle(Context2d ctx, Style style) {
if (style.getBackgroundColor() != null) {
ctx.setFillStyle(Converter.convert(style.getBackgroundColor()));
}
ColorOwn fgColor = getOverlay().getForegroundColor() != null ? getOverlay().getForegroundColor() : style.getForegroundColor();
if (fgColor != null) {
ctx.setStrokeStyle(Converter.convert(fgColor));
}
ctx.setLineWidth(style.getLineWidth());
setLineDash(ctx, style.getLineType(), style.getLineWidth());
}
示例15: redraw
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void redraw() {
Context2d graphics2d = canvas.getContext2d();
int w = canvas.getCoordinateSpaceWidth(), h = canvas.getCoordinateSpaceHeight();
graphics2d.setFillStyle(background);
graphics2d.fillRect(0, 0, w, h);
if (pageInfo == null)
return;
int subsample = toSubsample(zoom);
double scale = zoom / toZoom(subsample);
graphics2d.save();
int startX = w / 2 - centerX, startY = h / 2 - centerY;
graphics2d.translate(startX, startY);
graphics2d.scale(scale, scale);
graphics2d.translate(-startX, -startY);
graphics2d.scale(1, -1); // DjVu images have y-axis inverted
int tileSize = DjvuContext.getTileSize();
int pw = (int) (pageInfo.width * zoom), ph = (int) (pageInfo.height * zoom);
range.xmin = (int) (Math.max(0, centerX - w * 0.5) / tileSize / scale);
range.xmax = (int) Math.ceil(Math.min(pw, centerX + w * 0.5) / tileSize / scale);
range.ymin = (int) (Math.max(0, centerY - h * 0.5) / tileSize / scale);
range.ymax = (int) Math.ceil(Math.min(ph, centerY + h * 0.5) / tileSize / scale);
imagesArray = dataStore.getTileImages(page, subsample, range , imagesArray);
for (int y = range.ymin; y <= range.ymax; y++) {
for (int x = range.xmin; x <= range.xmax; x++) {
CanvasElement canvasElement = imagesArray[y - range.ymin][x - range.xmin];
for (int repeats = scale == 1 ? 1 : 3; repeats > 0; repeats--) {
graphics2d.drawImage(canvasElement, startX + x * tileSize,
-startY - y * tileSize - canvasElement.getHeight());
}
}
}
graphics2d.restore();
// missing tile graphics may exceed the page boundary
graphics2d.fillRect(startX + pw, 0, w, h);
graphics2d.fillRect(0, startY + ph, w, h);
DjvuContext.setTileRange(range, subsample);
}