當前位置: 首頁>>代碼示例>>Java>>正文


Java Context2d.save方法代碼示例

本文整理匯總了Java中com.google.gwt.canvas.dom.client.Context2d.save方法的典型用法代碼示例。如果您正苦於以下問題:Java Context2d.save方法的具體用法?Java Context2d.save怎麽用?Java Context2d.save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gwt.canvas.dom.client.Context2d的用法示例。


在下文中一共展示了Context2d.save方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: 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();
	}
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:23,代碼來源:CursorOverlay.java

示例2: redrawIfNecessary

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void redrawIfNecessary(Context2d g, double timestamp) {
  if (!isVisible()) {
    return;
  }
  if (redrawNeeded) {
    clearRect(g);
    render(g, timestamp);
  } else {
    g.save();
    g.translate(x, y);
    for (UiElement c : children) {
      c.redrawIfNecessary(g, timestamp);
    }
    g.restore();
  }
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:18,代碼來源:Panel.java

示例3: redrawIfNecessary

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void redrawIfNecessary(Context2d g, double timestamp) {
  if (!isVisible()) {
    return;
  }
  if (redrawNeeded) {
    clearRect(g);
    render(g, timestamp);
  } else {
    g.save();
    g.beginPath();
    g.rect(x, y, width, height);
    g.clip();
    g.translate(x + scrollOffset.x, y + scrollOffset.y);
    for (UiElement c : children) {
      c.redrawIfNecessary(g, timestamp);
    }
    g.restore();
  }
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:21,代碼來源:ScrollPanel.java

示例4: 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);
}
 
開發者ID:mateusz-matela,項目名稱:djvu-html5,代碼行數:41,代碼來源:SinglePageLayout.java

示例5: drawGrid

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
private void drawGrid() {
	Context2d ctx = canvasLayer.getContext();
	
	ctx.save();
	ctx.translate(0.5, 0.5);
	ctx.setStrokeStyle(CssColors.BLACK);
	ctx.setLineWidth(1);
	
	ctx.beginPath();

	// Horizontal grid lines
	for (int i = startX; i < height; i += stepY) {
		if (dashed) {
			drawDashedLine(startX, i, width, 2, 2, true, ctx);
		} else {
			ctx.moveTo(startX, i);
			ctx.lineTo(width, i);
		}
	}

	// Vertical grid lines
	for (int i = startY; i < width; i += stepX) {
		if (dashed) {
			drawDashedLine(i, startY, height, 2, 2, false, ctx);
		} else {
			ctx.moveTo(i, startY);
			ctx.lineTo(i, height);
		}

	}
	
	ctx.stroke();
	ctx.restore();
}
 
開發者ID:PsiAmp,項目名稱:punk-toads,代碼行數:35,代碼來源:Grid.java

示例6: paintFragmentNumbers

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
    public void paintFragmentNumbers(Context2d g) {
        if (mFragmentNoColor != null && mMolecule != null) {
            double averageBondLength = calculateAverageBondLength();
            g.save();
//            FillStrokeStyle oldStroke = g.getStrokeStyle();
//            FillStrokeStyle oldFill = g.getFillStyle();
            g.setStrokeStyle(mFragmentNoColor);
            g.setFillStyle(mFragmentNoColor);
            //Font font = Font.font("Helvetica", FontWeight.BOLD, (int) (1.6 * averageBondLength));
            int size = (int) (1.6 * averageBondLength);
            String font = "bold " + size + "px Helvetica";
            g.setFont(font);
//            com.sun.javafx.tk.FontMetrics fm = Toolkit.getToolkit().getFontLoader().getFontMetrics(font);
            for (int i = 0; i < mMolecule.length; i++) {
                if (mMolecule[i].getAllAtoms() != 0) {
                    Point cog = new Point();
                    for (int atom = 0; atom < mMolecule[i].getAllAtoms(); atom++) {
                        cog.x += mMolecule[i].getAtomX(atom);
                        cog.y += mMolecule[i].getAtomY(atom);
                    }
                    cog.x /= mMolecule[i].getAllAtoms();
                    cog.y /= mMolecule[i].getAllAtoms();
                    cog.x = (int) mDepictor[i].getTransformation().transformX(cog.x);
                    cog.y = (int) mDepictor[i].getTransformation().transformY(cog.y);

                    String str = (mReactantOrCoreCount == -1) ? "F" + (i + 1)
                            : (i < mReactantOrCoreCount) ? "" + (char) ('A' + i)
                            : (mIsMarkushStructure) ? "R" + (i + 1 - mReactantOrCoreCount)
                            : "P" + (i + 1 - mReactantOrCoreCount);
                    drawString(g,str,cog.x,cog.y);
//                    int width = (int) getStringWidth(str);
//                    g.fillText(str, cog.x - width / 2, cog.y + (int) (0.3 * fm.getLineHeight()));
                }
            }
            g.restore();
        }
    }
 
開發者ID:cheminfo,項目名稱:openchemlib-js,代碼行數:39,代碼來源:MoleculeDrawDepictor.java

示例7: paint

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void paint(Canvas canvas, Matrix matrix) {
	/*
	* paint image on canvas based on the original and with the transformations of the matrix.
	* */
	Context2d context2d = canvas.getContext2d();
	context2d.save();
	boolean xReversal = matrix.getXx() < 0;
	boolean yReversal = matrix.getYy() < 0;
	context2d.scale(xReversal ? -1 : 1, yReversal ? -1 : 1);
	double xValue = xReversal ? box.getMaxX() * -1 : box.getX();
	double yValue = yReversal ? box.getMaxY() * -1 : box.getY();
	context2d.drawImage(hiddenImageCanvas.getCanvasElement(), xValue, yValue, box.getWidth(), box.getHeight());
	context2d.restore();
}
 
開發者ID:geomajas,項目名稱:geomajas-project-client-gwt2,代碼行數:16,代碼來源:CanvasImageElement.java

示例8: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setGlobalAlpha(0.4);
  g.setFillStyle("#333");
  g.setStrokeStyle("#999");
  g.beginPath();
  GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
  g.closePath();
  g.fill();
  g.stroke();
  renderText(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:15,代碼來源:DefaultAccordianHandleSkin.java

示例9: render

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void render(Context2d g, double timestamp) {
  g.save();
  g.setGlobalAlpha(0.4);
  g.setFillStyle("#999");
  g.setStrokeStyle("#333");
  g.beginPath();
  GraphicsUtil.drawRoundedRect(g, 0.5, 0.5, width - 1, height - 1, 8);
  g.closePath();
  g.fill();
  g.stroke();
  renderText(g);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:15,代碼來源:DefaultButtonSkin.java

示例10: draw

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
@Override
public void draw(Context2d context, DisplayArea area, OnDrawnCallback cb) {
    double zoom = area.zoom();

    context.save();

    context.translate(-area.viewportLeft(), -area.viewportTop());
    context.scale(zoom, zoom);

    context.beginPath();
    context.moveTo(coords[0][0], coords[0][1]);

    for (int i = 1; i < coords.length; i++) {
        context.lineTo(coords[i][0], coords[i][1]);
    }

    context.setLineWidth(6);
    context.stroke();
    
    context.setGlobalAlpha(0.3);
    context.setFillStyle("white");
    context.fill();
    context.setGlobalAlpha(1.0);
    
    context.closePath();

    context.restore();
    
    cb.onDrawn();
}
 
開發者ID:jhu-digital-manuscripts,項目名稱:rosa,代碼行數:31,代碼來源:PolygonDrawable.java

示例11: 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);
  skin.width = width = DragButton.this.width;
  skin.height = height = DragButton.this.height;
  skin.getRenderer(DragButtonState.UP).render(g, timestamp);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:14,代碼來源:DragButton.java

示例12: tx

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
public void tx(Context2d ctx, Consumer<Context2d> draw) throws Exception {
    ctx.save();
    draw.accept(ctx);
    ctx.restore();
}
 
開發者ID:ibaca,項目名稱:rxcanvas-gwt,代碼行數:6,代碼來源:RxCanvas.java

示例13: clearRect

import com.google.gwt.canvas.dom.client.Context2d; //導入方法依賴的package包/類
protected void clearRect(Context2d g) {
  g.save();
  g.translate(x, y);
  g.clearRect(0, 0, width, height);
  g.restore();
}
 
開發者ID:cjmalloy,項目名稱:GwtGameUi,代碼行數:7,代碼來源:UiElement.java


注:本文中的com.google.gwt.canvas.dom.client.Context2d.save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。