In a component I must display several lines of colored pixels. Each pixel of the line is given a color. What kind of component is suitable to build the line or what kind of component is suitable to hold pixels?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To me the best (but maybe not easiest) way would be implementing a custom
Paintclass that allows for setting colour regions – a bit like theGradientPaintclasses but more flexible.Then you would call
Graphics2D.setPaint(myPaint)just before you draw the line.The
Paintimplementation could offer a methodsetColorForRegion(double start, double end, Color color)withstartandendtaking values between 0.0 and 1.0 to mark a region on the line.Might be a bit complicated to implement the
Paintclass, but the benefit is, that you can resize the lines and draw them in any direction while preserving the color pattern.