GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — mxgraph/java/src/com/mxgraph/shape/mxLabelShape.java at master · optionalg/mxgraph Expand file tree/ Copy pathmxLabelShape.javaMore file actions 146 lines (127 loc) · 3.79 KB / Copy pathmxLabelShape.javaFile metadata and controls146 lines (127 loc) · 3.79 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 package com.mxgraph.shape; import java.awt.Color; import java.awt.GradientPaint; import java.awt.Rectangle; import java.awt.geom.GeneralPath; import java.util.Map; import com.mxgraph.canvas.mxGraphics2DCanvas; import com.mxgraph.util.mxConstants; import com.mxgraph.util.mxRectangle; import com.mxgraph.util.mxUtils; import com.mxgraph.view.mxCellState; public class mxLabelShape extends mxImageShape { /** * */ public void paintShape(mxGraphics2DCanvas canvas, mxCellState state) { super.paintShape(canvas, state); if (mxUtils.isTrue(state.getStyle(), mxConstants.STYLE_GLASS, false)) { drawGlassEffect(canvas, state); } } /** * Draws the glass effect */ public static void drawGlassEffect(mxGraphics2DCanvas canvas, mxCellState state) { double size = 0.4; canvas.getGraphics().setPaint( new GradientPaint((float) state.getX(), (float) state.getY(), new Color(1, 1, 1, 0.9f), (float) (state.getX()), (float) (state.getY() + state.getHeight() * size), new Color(1, 1, 1, 0.3f))); float sw = (float) (mxUtils.getFloat(state.getStyle(), mxConstants.STYLE_STROKEWIDTH, 1) * canvas.getScale() / 2); GeneralPath path = new GeneralPath(); path.moveTo((float) state.getX() - sw, (float) state.getY() - sw); path.lineTo((float) state.getX() - sw, (float) (state.getY() + state.getHeight() * size)); path.quadTo((float) (state.getX() + state.getWidth() * 0.5), (float) (state.getY() + state.getHeight() * 0.7), (float) (state.getX() + state.getWidth() + sw), (float) (state.getY() + state.getHeight() * size)); path.lineTo((float) (state.getX() + state.getWidth() + sw), (float) state.getY() - sw); path.closePath(); canvas.getGraphics().fill(path); } /** * */ public Rectangle getImageBounds(mxGraphics2DCanvas canvas, mxCellState state) { Map<String, Object> style = state.getStyle(); double scale = canvas.getScale(); String imgAlign = mxUtils.getString(style, mxConstants.STYLE_IMAGE_ALIGN, mxConstants.ALIGN_LEFT); String imgValign = mxUtils.getString(style, mxConstants.STYLE_IMAGE_VERTICAL_ALIGN, mxConstants.ALIGN_MIDDLE); int imgWidth = (int) (mxUtils.getInt(style, mxConstants.STYLE_IMAGE_WIDTH, mxConstants.DEFAULT_IMAGESIZE) * scale); int imgHeight = (int) (mxUtils.getInt(style, mxConstants.STYLE_IMAGE_HEIGHT, mxConstants.DEFAULT_IMAGESIZE) * scale); int spacing = (int) (mxUtils .getInt(style, mxConstants.STYLE_SPACING, 2) * scale); mxRectangle imageBounds = new mxRectangle(state); if (imgAlign.equals(mxConstants.ALIGN_CENTER)) { imageBounds.setX(imageBounds.getX() + (imageBounds.getWidth() - imgWidth) / 2); } else if (imgAlign.equals(mxConstants.ALIGN_RIGHT)) { imageBounds.setX(imageBounds.getX() + imageBounds.getWidth() - imgWidth - spacing - 2); } else // LEFT { imageBounds.setX(imageBounds.getX() + spacing + 4); } if (imgValign.equals(mxConstants.ALIGN_TOP)) { imageBounds.setY(imageBounds.getY() + spacing); } else if (imgValign.equals(mxConstants.ALIGN_BOTTOM)) { imageBounds.setY(imageBounds.getY() + imageBounds.getHeight() - imgHeight - spacing); } else // MIDDLE { imageBounds.setY(imageBounds.getY() + (imageBounds.getHeight() - imgHeight) / 2); } imageBounds.setWidth(imgWidth); imageBounds.setHeight(imgHeight); return imageBounds.getRectangle(); } /** * */ public Color getFillColor(mxGraphics2DCanvas canvas, mxCellState state) { return mxUtils.getColor(state.getStyle(), mxConstants.STYLE_FILLCOLOR); } /** * */ public Color getStrokeColor(mxGraphics2DCanvas canvas, mxCellState state) { return mxUtils .getColor(state.getStyle(), mxConstants.STYLE_STROKECOLOR); } /** * */ public boolean hasGradient(mxGraphics2DCanvas canvas, mxCellState state) { return true; } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |