📄 dvgraphicsinfox.java
字号:
package edu.odu.cs.zeil.AlgAE.Client.DataViewer;import java.awt.Canvas;import java.awt.Dimension;import java.awt.Font;import java.awt.FontMetrics;import java.awt.Graphics;import java.awt.Image;import edu.odu.cs.zeil.AlgAE.Client.DataViewer.DataGraph.GraphicsInfo;/** * Graphics context information, with support for double buffering. * * @author Steven J. Zei */public class DVGraphicsInfo extends GraphicsInfo{ /** * The image that new drawing is written into. */ Image drawTo; /** * The image with old drawing that the canvas is repainted from. */ Image repaintFrom; /** * Build a graphics context. * * @param c The canvas that this graphic information is associated with. */ DVGraphicsInfo() { super(); repaintFrom = drawTo = null; textOffset.width = 0; } /** * Initialize the graphics data member <code>g</code> to a valid * graphics context and sets the canvasSize and textOffset values. */ public void openGraphics() { canvasSize = canvas.getSize(); if (drawTo == null) { drawTo = canvas.createImage (canvasSize.width, canvasSize.height); g = drawTo.getGraphics(); g.setColor(canvas.getBackground()); g.fillRect(0, 0, canvasSize.width, canvasSize.height); g.setFont (font); if (textOffset.width == 0) { FontMetrics fm = g.getFontMetrics(); textOffset.width = (fm.charWidth('X') + 1) / 2; textOffset.height = (fm.getAscent() + 1) / 2; } } } /** * Indicates that the graphics data member <code>g</code> is no longer * in use. * * @param wasWrittenTo Input parameter, true if anything has been * written to the graphics context since it was opened. * False if we were "only looking". */ public void closeGraphics(boolean wasWrittenTo) { if (wasWrittenTo) { repaintFrom = drawTo; drawTo = null; } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -