本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.fillRect方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.fillRect方法的具體用法?Java Context2d.fillRect怎麽用?Java Context2d.fillRect使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.gwt.canvas.dom.client.Context2d
的用法示例。
在下文中一共展示了Context2d.fillRect方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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
示例4: 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
示例5: 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;
}
示例6: 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 );
}
}
示例7: 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);
}
示例8: render
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void render() {
Context2d context = canvas.getContext2d();
context.setFillStyle("white");
context.setStrokeStyle("grey");
context.fillRect(0, 0, 600, 600);
context.save();
context.translate(0, 600);
context.scale(1, -1);
context.scale(100, 100);
context.setLineWidth(0.01);
for (Body body = scene.getWorld().getBodyList(); body != null; body = body.getNext()) {
Vec2 center = body.getPosition();
context.save();
context.translate(center.x, center.y);
context.rotate(body.getAngle());
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
Shape shape = fixture.getShape();
if (shape.getType() == ShapeType.CIRCLE) {
CircleShape circle = (CircleShape) shape;
context.beginPath();
context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
context.closePath();
context.stroke();
} else if (shape.getType() == ShapeType.POLYGON) {
PolygonShape poly = (PolygonShape) shape;
Vec2[] vertices = poly.getVertices();
context.beginPath();
context.moveTo(vertices[0].x, vertices[0].y);
for (int i = 1; i < poly.getVertexCount(); ++i) {
context.lineTo(vertices[i].x, vertices[i].y);
}
context.closePath();
context.stroke();
}
}
context.restore();
}
context.restore();
}
示例9: paintToCanvas
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
/**
* Paints the given page of the given {@link Layout} at the given zoom level
* into the given {@link CanvasElement}, which is resized to include the whole page.
* The size in pixel is also returned.
*/
public static Size2i paintToCanvas(Layout layout, int pageIndex, float zoom,
com.google.gwt.canvas.client.Canvas canvas) {
Context2d context = canvas.getContext2d();
//compute size
Page page = layout.getPages().get(pageIndex);
Size2f pageSize = page.getFormat().getSize();
int width = Units.mmToPxInt(pageSize.width, zoom);
int height = Units.mmToPxInt(pageSize.height, zoom);
//resize canvas and coordinate space
canvas.setWidth(width + "px");
canvas.setHeight(height + "px");
int coordSpaceFactor = 2; //double resolution: smoother
canvas.setCoordinateSpaceWidth(width * coordSpaceFactor);
canvas.setCoordinateSpaceHeight(height * coordSpaceFactor);
context.scale(coordSpaceFactor, coordSpaceFactor);
//white page
context.setFillStyle("white");
context.fillRect(0, 0, width, height);
//paint layout
LayoutRenderer.paintToCanvas(layout, pageIndex, zoom, origin,
new GwtCanvas(context, CanvasFormat.Raster,
CanvasDecoration.Interactive, CanvasIntegrity.Perfect));
return new Size2i(width, height);
}
示例10: startGame
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
protected void startGame() {
Context2d context = view.getCanvas().getContext2d();
int w = context.getCanvas().getWidth();
int h = context.getCanvas().getHeight();
context.setFillStyle("#" + Colour.WHITE.toHexString());
context.fillRect(0, 0, w, h);
icyVm.startGame();
processVmOutput();
view.getTextBox().setFocus(true);
}
示例11: execute
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public boolean execute() {
Context2d context = canvas.getContext2d();
int w = context.getCanvas().getWidth();
int h = context.getCanvas().getHeight();
context.setFillStyle("#" + Colour.BLACK.toHexString());
context.fillRect(0, 0, w, h);
imageData = context.getImageData(0, 0, width, height);
putImageDataOnCanvas();
return false;
}
示例12: drawBackground
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawBackground() {
Context2d ctx = backgroundCanvasLayer.getContext();
ctx.translate(0.5, 0.5);
ctx.setFillStyle(CssColors.LIGHT_GREY);
ctx.fillRect(0, 0, canvasWidth, canvasHeight);
}
示例13: drawBackground
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawBackground(Context2d context2d, int w, int h) {
context2d.clearRect(0, 0, w, h);
context2d.setFillStyle(WHITE);
context2d.fillRect(0, 0, w, h);
}
示例14: update
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void update(UpdateConfig config)
{
clear();
Context2d context = m_canvas.getContext2d();
Context2d stageContext = m_stagingCanvas.getContext2d();
double cellSize = config.cellSize;
cellSize -= m_pinch*2;
double cellSize_div2 = cellSize/2;
int limit_n = config.startN + config.down;
int limit_m = config.startM + config.across;
boolean foundFirstCell = false;
//
for( int n = config.startN; n < limit_n; n++ )
{
for( int m = config.startM; m < limit_m; m++ )
{
int skip = m_skipper.skip(m, n);
if( skip == 1 )
{
continue;
}
else if( skip > 1 )
{
m += skip;
m -= 1; // will get incremented in for loop so offsetting here.
continue;
}
int index = n*config.totalGridSize + m;
if( !config.ownership.isSet(index) ) continue;
int offsetM = m - config.startM_meta;
int offsetN = n - config.startN_meta;
int offsetM_mod = offsetM % config.metaSubCellCount;
int offsetN_mod = offsetN % config.metaSubCellCount;
offsetM -= offsetM_mod;
offsetN -= offsetN_mod;
offsetM /= config.metaSubCellCount;
offsetN /= config.metaSubCellCount;
double currX = config.startX_meta + offsetM * config.metaCellSize + offsetM_mod * config.cellSizePlusPadding;
double currY = config.startY_meta + offsetN * config.metaCellSize + offsetN_mod * config.cellSizePlusPadding;
currX += m_pinch;
currY += m_pinch;
if( !foundFirstCell )
{
stageContext.fillRect(0, 0, cellSize, cellSize);
if( m_animation != null )
{
m_animation.draw(stageContext, (int)cellSize_div2, (int)cellSize_div2, config.scaling);
}
foundFirstCell = true;
}
context.drawImage(m_stagingCanvasElement, 0, 0, cellSize, cellSize, currX, currY, cellSize, cellSize);
m_clear = false;
}
}
m_animation.update(config.timestep);
}
示例15: drawElement
import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawElement() {
long time = currentTime.getTime() - startTime.getTime();
double length = (((double) time) / 60000.0) * lenghtOfAMinute;
Context2d context = canvas.getContext2d();
context.clearRect(0, 0, scroll.getElement().getScrollWidth(), scroll
.getElement().getScrollHeight());
context.setFillStyle(color);
context.setStrokeStyle(color);
context.fillRect(0, 5, length, 5);
context.fill();
context.stroke();
context.beginPath();
context.moveTo(length, 0);
context.lineTo(length + 7, 7);
context.lineTo(length, 15);
context.lineTo(length, 0);
context.closePath();
context.stroke();
context.fill();
int ticDist = (int) ((lenghtOfAMinute * (double) unitMs[unit]) / 60000.0);
int count = (int) (time / unitMs[unit]);
drawTics(count, ticDist, unitFactor[unit], units[unit]);
ReflectionToolHtml.reflectionToolInstance.drawZoom();
if (ticDist < 35 && unit < (units.length - 1)) {
unit++;
logger.log(Level.INFO,
"ReflectionTool: Timeline.drawElement(): Unit switched to "
+ unit);
} else if (ticDist > 200 && unit > 0) {
unit--;
logger.log(Level.INFO,
"ReflectionTool: Timeline.drawElement(): Unit switched to "
+ unit);
}
}