public void draw( GFX gfx, ListView listView, Paint paint, int index, double x, double y, double w, double h) { gfx.translate(x, y); if (paint instanceof PatternPaint) { PatternPaint pp = (PatternPaint) paint; double pw = pp.getImage().getWidth(); double ph = pp.getImage().getHeight(); double sx = w / pw; double sy = h / ph; gfx.scale(sx, sy); gfx.setPaint(pp); gfx.fillRect(0, 0, pw, ph); gfx.scale(1 / sx, 1 / sy); } else { gfx.setPaint(paint); gfx.fillRect(0, 0, w, h); } gfx.setPaint(FlatColor.BLACK); gfx.drawRect(0, 0, w, h); gfx.translate(-x, -y); }
@Override public void draw(GFX gfx) { float[] curr = toHSB(color); float[] start = toHSB(startColor); // hue, vertical gfx.translate(centerPoint.getX(), centerPoint.getY()); for (double i = 0; i < 200; i++) { FlatColor c = FlatColor.hsb(i / 200 * 360.0, curr[1], curr[2]); gfx.setPaint(c); double y = start[0] * 200; gfx.drawLine(-5, i - y, +5, i - y); } gfx.translate(-centerPoint.getX(), -centerPoint.getY()); // saturation, 30 degrees gfx.translate(centerPoint.getX(), centerPoint.getY()); for (double i = 0; i < 200; i++) { FlatColor c = FlatColor.hsb(curr[0] * 360, i / 200.0, curr[2]); gfx.setPaint(c); double sin = Math.sin(Math.toRadians(30)); double cos = Math.cos(Math.toRadians(30)); double x = cos * i - cos * start[1] * 200 + 0; double y = sin * i - sin * start[1] * 200 + 0; // tx = cos(30)*i // tx/cos(30) = i gfx.drawLine(x, y - 5, x, y + 5); } gfx.translate(-centerPoint.getX(), -centerPoint.getY()); // brightness, 150 degrees gfx.translate(centerPoint.getX(), centerPoint.getY()); for (double i = 0; i < 200; i++) { FlatColor c = FlatColor.hsb(curr[0] * 360, curr[1], i / 200.0); gfx.setPaint(c); double sin = Math.sin(Math.toRadians(150)); double cos = Math.cos(Math.toRadians(150)); double x = cos * i - cos * start[2] * 200; double y = sin * i - sin * start[2] * 200; gfx.drawLine(x, y - 5, x, y + 5); } gfx.translate(-centerPoint.getX(), -centerPoint.getY()); gfx.setPaint(color); double s = 16; gfx.fillOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s); gfx.setPaint(FlatColor.BLACK); gfx.drawOval(centerPoint.getX() - s / 2, centerPoint.getY() - s / 2, s, s); gfx.drawRect(0, 0, getWidth(), getHeight()); }
@Override public void draw(GFX g) { if (!isVisible()) return; boxPainter.draw(g, styleInfo, sizeInfo, ""); Bounds leftArrowBounds = new Bounds(0, 0, arrowLength, getHeight()); Bounds rightArrowBounds = new Bounds(getWidth() - arrowLength, 0, arrowLength, getHeight()); Bounds thumbBounds = calculateThumbBounds(); if (isVertical()) { leftArrowBounds = new Bounds(0, 0, getWidth(), arrowLength); rightArrowBounds = new Bounds(0, getHeight() - arrowLength, getWidth(), arrowLength); } Bounds trackBounds = getTrackBounds(); trackSizeInfo.width = trackBounds.getWidth(); trackSizeInfo.height = trackBounds.getHeight(); g.translate(trackBounds.getX(), trackBounds.getY()); trackPainter.draw(g, trackStyleInfo, trackSizeInfo, ""); g.translate(-trackBounds.getX(), -trackBounds.getY()); leftArrowSizeInfo.width = leftArrowBounds.getWidth(); leftArrowSizeInfo.height = leftArrowBounds.getHeight(); leftArrowPainter.draw(g, leftArrowStyleInfo, leftArrowSizeInfo, ""); g.translate(rightArrowBounds.getX(), rightArrowBounds.getY()); rightArrowSizeInfo.width = rightArrowBounds.getWidth(); rightArrowSizeInfo.height = rightArrowBounds.getHeight(); rightArrowPainter.draw(g, rightArrowStyleInfo, rightArrowSizeInfo, ""); g.translate(-rightArrowBounds.getX(), -rightArrowBounds.getY()); g.translate(thumbBounds.getX(), thumbBounds.getY()); thumbSizeInfo.width = thumbBounds.getWidth(); thumbSizeInfo.height = thumbBounds.getHeight(); thumbPainter.draw(g, thumbStyleInfo, thumbSizeInfo, ""); g.translate(-thumbBounds.getX(), -thumbBounds.getY()); // draw the arrows /* g.setPaint(new FlatColor(0x303030)); if(isVertical()) { GraphicsUtil.fillUpArrow(g,2,2,10); GraphicsUtil.fillDownArrow(g,2,getHeight()-2-10,10); } else { GraphicsUtil.fillLeftArrow(g,2,2,10); GraphicsUtil.fillRightArrow(g,getWidth()-2-10,2,10); } */ }