> /* > * Copyright (C) 1999 - 2006 by Environmental Systems Research Institute Inc. > * All Rights Reserved. > * > * N O T I C E > * > * THIS MATERIAL IS CONSIDERED A TRADE SECRET BY ESRI. > * UNAUTHORIZED ACCESS IS PROHIBITED. > * > * $Workfile:$ $Revision:$ > */
Umm. After such introduction to the test I think I'd have to burn my eyes after reading it! =) Dmitri On Wed, Jun 28, 2006 at 09:57:37AM -0700, Russell East wrote: > Hi, > the attached sample app uses Java2D dash pattern to try to create a > railway pattern, but the result isn't very good. > > The code is specifying the dash array as { 4.0f, 4.0f } but I'm seeing > variable results: > o on the top line it seems more like {5, 3} > o on the left line seems more like { 6, 2, 5, 3 } and > o on the bottom line does not look dashed at all > > Is it something I'm doing wrong in my code, or known problem? > > -- Russell > > =========================================================================== > To unsubscribe, send email to [EMAIL PROTECTED] and include in the body > of the message "signoff JAVA2D-INTEREST". For general help, send email to > [EMAIL PROTECTED] and include in the body of the message "help". > /* > * Copyright (C) 1999 - 2006 by Environmental Systems Research Institute Inc. > * All Rights Reserved. > * > * N O T I C E > * > * THIS MATERIAL IS CONSIDERED A TRADE SECRET BY ESRI. > * UNAUTHORIZED ACCESS IS PROHIBITED. > * > * $Workfile:$ $Revision:$ > */ > > package com.esri.mc.app; > > import javax.swing.*; > import java.awt.*; > import java.awt.geom.GeneralPath; > > /** > * dash lines look wrong > */ > public class RailwayLines extends JFrame { > > public static void main(String[] args) { > new RailwayLines().setVisible(true); > } > > public RailwayLines() { > this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); > this.setBounds(200, 200, 500, 300); > String text = System.getProperty("java.vm.version"); > this.setTitle(text); > MyCanvas canvas = new MyCanvas(); > this.getContentPane().add(canvas); > } > } > > final class MyCanvas extends JComponent { > private Stroke topStroke, backStroke; > private Color topColor, backColor; > private GeneralPath path; > > MyCanvas() { > topStroke = constructTopStroke(); > backStroke = constructBackStroke(); > topColor = Color.WHITE; > backColor = new Color(102, 102, 102); > path = constructPath(); > } > > private GeneralPath constructPath() { > GeneralPath path = new GeneralPath(); > path.moveTo(100.0f, 100.0f); > path.lineTo(200.0f, 200.0f); > path.lineTo(400.0f, 200.0f); > path.lineTo(400.0f, 100.0f); > path.closePath(); > return path; > } > > private Stroke constructBackStroke() { > float width = 4.0f; > int cap = BasicStroke.CAP_ROUND; > int join = BasicStroke.JOIN_ROUND; > return new BasicStroke(width, cap, join); > } > > private Stroke constructTopStroke() { > float width = 2.0f; > int cap = BasicStroke.CAP_ROUND; > int join = BasicStroke.JOIN_ROUND; > float miterLimit = 10.f; > float[] dash = { 4.0f, 4.0f }; > float dashPhase = 0.0f; > return new BasicStroke(width, cap, join, miterLimit, dash, > dashPhase); > } > > protected void paintComponent(Graphics g) { > super.paintComponent(g); > Graphics2D g2 = (Graphics2D)g; > g2.setColor(backColor); > g2.setStroke(backStroke); > g2.draw(path); > g2.setColor(topColor); > g2.setStroke(topStroke); > g2.draw(path); > } > } =========================================================================== To unsubscribe, send email to [EMAIL PROTECTED] and include in the body of the message "signoff JAVA2D-INTEREST". For general help, send email to [EMAIL PROTECTED] and include in the body of the message "help".