public void setFillColor(String value) { if (state.fillColorValue == null || !state.fillColorValue.equals(value)) { state.fillColorValue = value; state.fillColor = null; // Setting fill color resets gradient paint state.gradientPaint = null; } }
public void setGradient( String color1, String color2, double x, double y, double w, double h, String direction, double alpha1, double alpha2) { // LATER: Add lazy instantiation and check if paint already created float x1 = (float) ((state.dx + x) * state.scale); float y1 = (float) ((state.dy + y) * state.scale); float x2 = (float) x1; float y2 = (float) y1; h *= state.scale; w *= state.scale; if (direction == null || direction.length() == 0 || direction.equals(mxConstants.DIRECTION_SOUTH)) { y2 = (float) (y1 + h); } else if (direction.equals(mxConstants.DIRECTION_EAST)) { x2 = (float) (x1 + w); } else if (direction.equals(mxConstants.DIRECTION_NORTH)) { y1 = (float) (y1 + h); } else if (direction.equals(mxConstants.DIRECTION_WEST)) { x1 = (float) (x1 + w); } Color c1 = parseColor(color1); if (alpha1 != 1) { c1 = new Color(c1.getRed(), c1.getGreen(), c1.getBlue(), (int) (alpha1 * 255)); } Color c2 = parseColor(color2); if (alpha2 != 1) { c2 = new Color(c2.getRed(), c2.getGreen(), c2.getBlue(), (int) (alpha2 * 255)); } state.gradientPaint = new GradientPaint(x1, y1, c1, x2, y2, c2, true); // Resets fill color state.fillColorValue = null; }