static int getRegularCount(Way w, Node end) { final int count = getCount(w); if (w.hasDirectionKeys()) { // TODO check for oneway=-1 if (w.lastNode().equals(end)) { return count; } else { return 0; } } else { if (w.lastNode().equals(end)) { return (count + 1) / 2; // round up in direction of end } else { return count / 2; // round down in other direction } } }
@Override public void paintPrimitive( OsmPrimitive primitive, MapPaintSettings paintSettings, StyledMapRenderer painter, boolean selected, boolean outermember, boolean member) { Way w = (Way) primitive; /* show direction arrows, if draw.segment.relevant_directions_only is not set, the way is tagged with a direction key (even if the tag is negated as in oneway=false) or the way is selected */ boolean showOrientation; if (defaultSelectedHandling) { showOrientation = !isModifier && (selected || paintSettings.isShowDirectionArrow()) && !paintSettings.isUseRealWidth(); } else { showOrientation = wayDirectionArrows; } boolean showOneway = !isModifier && !selected && !paintSettings.isUseRealWidth() && paintSettings.isShowOnewayArrow() && w.hasDirectionKeys(); boolean onewayReversed = w.reversedDirection(); /* head only takes over control if the option is true, the direction should be shown at all and not only because it's selected */ boolean showOnlyHeadArrowOnly = showOrientation && !selected && paintSettings.isShowHeadArrowOnly(); Node lastN; Color myDashedColor = dashesBackground; BasicStroke myLine = line, myDashLine = dashesLine; if (realWidth > 0 && paintSettings.isUseRealWidth() && !showOrientation) { float myWidth = (int) (100 / (float) (painter.getCircum() / realWidth)); if (myWidth < line.getLineWidth()) { myWidth = line.getLineWidth(); } myLine = new BasicStroke( myWidth, line.getEndCap(), line.getLineJoin(), line.getMiterLimit(), line.getDashArray(), line.getDashPhase()); if (dashesLine != null) { myDashLine = new BasicStroke( myWidth, dashesLine.getEndCap(), dashesLine.getLineJoin(), dashesLine.getMiterLimit(), dashesLine.getDashArray(), dashesLine.getDashPhase()); } } Color myColor = color; if (defaultSelectedHandling && selected) { myColor = paintSettings.getSelectedColor(color.getAlpha()); } else if (member || outermember) { myColor = paintSettings.getRelationSelectedColor(color.getAlpha()); } else if (w.isDisabled()) { myColor = paintSettings.getInactiveColor(); myDashedColor = paintSettings.getInactiveColor(); } painter.drawWay( w, myColor, myLine, myDashLine, myDashedColor, offset, showOrientation, showOnlyHeadArrowOnly, showOneway, onewayReversed); if ((paintSettings.isShowOrderNumber() || (paintSettings.isShowOrderNumberOnSelectedWay() && selected)) && !painter.isInactiveMode()) { int orderNumber = 0; lastN = null; for (Node n : w.getNodes()) { if (lastN != null) { orderNumber++; painter.drawOrderNumber(lastN, n, orderNumber, myColor); } lastN = n; } } }