@Override public void prepare() { // adjust bounds (image size) to board zoom updateBounds(); // create image for buffer image = createNewHexImage(); Graphics2D graph = (Graphics2D)image.getGraphics(); GUIPreferences.AntiAliasifSet(graph); // get a big font and test to see which font size will fit // the hex shape Font textFont = new Font("SansSerif", 0, 1000); graph.setFont(textFont); FontMetrics fm = graph.getFontMetrics(graph.getFont()); Rectangle2D rect = fm.getStringBounds(spriteText, graph); float factor = 1; if (rect.getHeight() > bounds.getHeight()) factor = (float)bounds.getHeight()/(float)rect.getHeight(); if ((rect.getWidth()*factor) > bounds.getWidth()) factor = Math.min(factor, ((float)bounds.getWidth()/(float)rect.getWidth())); // make smaller to actually fit the hex shape factor = factor*0.7f; // set the font and draw the text Font textFontS = new Font("SansSerif", 0, (int)(factor*1000)); graph.setFont(textFontS); Point pos = new Point((int)(bounds.getWidth()/2),(int)(bounds.getHeight()/2)); bv.drawTextShadow(graph,spriteText,pos,textFontS); bv.drawCenteredText(graph, spriteText, pos, spriteColor, false); }
GUIPreferences.AntiAliasifSet(graph);
@Override public void prepare() { // adjust bounds (image size) to board zoom updateBounds(); // create image for buffer image = createNewHexImage(); Graphics2D graph = (Graphics2D)image.getGraphics(); GUIPreferences.AntiAliasifSet(graph); // scale the following draws according to board zoom graph.scale(bv.scale, bv.scale); // colored polygon at the hex border graph.setColor(color); graph.fill(getHexBorderArea(facing.getIntValue(), CUT_INSIDE, borderW, inset)); // draw the movement modifier if it's readable if (fontSize * bv.scale > 4) { graph.setFont(graph.getFont().deriveFont(fontSize)); Point2D.Double pos = getHexBorderAreaMid(facing.getIntValue(), borderW, inset); bv.drawCenteredText(graph, modifier, (float)pos.x, (float)pos.y, fontColor, false); } graph.dispose(); } }
GUIPreferences.AntiAliasifSet(graph);
GUIPreferences.AntiAliasifSet(g);
Transparency.TRANSLUCENT); Graphics2D graph = (Graphics2D)image.getGraphics(); GUIPreferences.AntiAliasifSet(graph);
GUIPreferences.AntiAliasifSet(graph);