/* Generated by Together */ package SesameGUI; import java.awt.Graphics2D; import java.awt.*; import java.awt.geom.*; import javax.swing.*; import java.text.NumberFormat; import java.awt.font.FontRenderContext; public class AbsoluteVerticalScale extends VerticalScale { public AbsoluteVerticalScale(SpectrumView view) { super(view); } public void draw(Graphics2D g) { g.setPaint(Color.gray); double iter; double pos; DoubleWrapper paneStep = new DoubleWrapper(); iter = getLowerVisibleBound(); paneStep.value = getStep(); real2PaneAbsolute(paneStep); g.draw(new Line2D.Double(getView().getLeftMargin(), getView().getBottomMargin(), getView().getLeftMargin(), getView().getTopMargin())); if (isBoxScale()) g.draw(new Line2D.Double(getView().getRightMargin(), getView().getBottomMargin(), getView().getRightMargin(), getView().getTopMargin())); // draw tickers pos = getView().getBottomMargin(); NumberFormat formater = NumberFormat.getNumberInstance(); formater.setMaximumFractionDigits(2); FontRenderContext context = g.getFontRenderContext(); int out; if (isBoxScale()) out = 2; else out = 0; for (iter = getLowerVisibleBound() - getStep(); iter < getUpperVisibleBound(); iter += getStep()) { if (isShowGrid()) g.draw(new Line2D.Double(getView().getLeftMargin() - 2, pos, getView().getRightMargin() + out, pos)); else { g.draw(new Line2D.Double(getView().getLeftMargin() - 2, pos, getView().getLeftMargin(), pos)); if (isBoxScale()) g.draw(new Line2D.Double(getView().getRightMargin() - 2, pos, getView().getRightMargin(), pos)); } g.scale(1.0, -1.0); Rectangle2D bounds = g.getFont().getStringBounds(formater.format(iter + getStep()), context); g.drawString(formater.format(iter + getStep()), (int)(55 - bounds.getWidth()), (int)pos * (-1)); g.scale(1.0, -1.0); pos += paneStep.value; } g.setPaint(Color.black); g.rotate(4.71); g.scale(-1.0, 1.0); Rectangle2D bounds1 = g.getFont().getStringBounds(getLabel(), context); g.drawString(getLabel(), (int)(getView().getBottomMargin() + (((getView().getTopMargin() - getView().getBottomMargin()) / 2.0) - (bounds1.getWidth() / 2.0))), 12); g.scale(-1.0, 1.0); g.rotate(-4.71); } }