/** * Create horizontal line * * @param display - active {@link Display} * @param g - active {@link ViewportGraphics} * @param sx - Square width * @param lw - line width * @param current - Current square coordinate (corner) * @param next - Next square coordinate (corner) * @param gap - Gap where label is inserted (pixels) * @param bold - flag controlling line width * @param lines - already created square lines * @return 'next' coordinate */ private Point horz( Display display, ViewportGraphics g, int sx, int lw, Point current, Point next, boolean gap, boolean bold, List<Line> lines) { // Initialize List<Path> paths = new ArrayList<Path>(2); // Create first segment Path path = new Path(display); // Move to last point path.moveTo(current.x, current.y); // Insert gap? if (gap) { // Calculate gap/2 int offset = Math.max(1, g.getFontHeight()); // End first segment before mid-point Point p = offset(current, next, -offset); path.lineTo(p.x, p.y); paths.add(path); // Create second segment path = new Path(display); // Move past mid-point p = offset(current, next, offset); path.moveTo(p.x, p.y); } // Close path path.lineTo(next.x - (bold ? 2 * lw : lw), next.y); paths.add(path); lines.add(new Line(paths, bold ? 2 * lw : lw)); // Finished return gap ? offset(current, next, 0) : next; }