paint

Problem with Painting in Java Swing App in Java 1.6

我的未来我决定 提交于 2019-12-01 06:10:36
I'm working on a Swing application (currently running on Java 1.6 update 11) which has some intermittent paint refresh problems (e.g. there are artifacts etc.). This only happens to some users of our application but not others. After doing some research, I found that setting the property sun.java2d.d3d to false may help and in fact, it helped for one of our users. Now that some other users are complaining about the issue, I'm thinking of setting the property to false for all users. My basic questions are the following: What exactly is the cause of this? Is it the video card? Is it the driver?

Call paint event from mouse move event

本秂侑毒 提交于 2019-12-01 04:42:43
问题 When mouse move over a panel2, I need to draw lines. So far I have done following public Form1() { InitializeComponent(); } private void panel2_Paint(object sender, PaintEventArgs e) { if (isDragging) { letsPaint(sender, e); } } private void panel2_MouseMove(object sender, MouseEventArgs e) { if (isDragging) { mouseMoveX = e.X; mouseMoveY = e.Y; this.Paint += new PaintEventHandler(panel2_Paint); } } private void letsPaint(object sender, PaintEventArgs e) { Pen blackpen = new Pen(Color.Black,

Draw background of custom View from .png file on Android

你离开我真会死。 提交于 2019-12-01 04:00:10
问题 I created a custom View by extending from View. In onDraw() I managed to draw some circles and other stuff. But now I want to add a background from a resource (sd card or a stream) which is actually a map I download from our server and than draw on it. It's for Android 8+ @Override protected void onDraw(Canvas canvas) { Canvas g = canvas; String file = "/mnt/sdcard/download/tux.png"; Bitmap bg = null; try { bg = BitmapFactory.decodeFile(file); g.setBitmap(bg); } catch (Exception e) { Log.d(

Problem with Painting in Java Swing App in Java 1.6

喜你入骨 提交于 2019-12-01 03:57:05
问题 I'm working on a Swing application (currently running on Java 1.6 update 11) which has some intermittent paint refresh problems (e.g. there are artifacts etc.). This only happens to some users of our application but not others. After doing some research, I found that setting the property sun.java2d.d3d to false may help and in fact, it helped for one of our users. Now that some other users are complaining about the issue, I'm thinking of setting the property to false for all users. My basic

Java: Using graphics component within an ActionListener

这一生的挚爱 提交于 2019-12-01 01:45:59
I have two separate class and driver files, and in the class file I create the paint method: public void paint(Graphics g){ g.drawLine(...... .... //along with all of my other draw commands } Further down in the code, I create a JButton and within this button's action listener I don't know how to use a Graphics object to create more graphics in the JFrame. Should I be adding something to my driver to make this happen, or is there a way to use these graphics within my action listener? Thank you, and any help is appreciated. Paul Samsotha You need to draw everything within the paint method. The

Soft Paint Bucket Fill: Colour Equality

末鹿安然 提交于 2019-12-01 01:28:08
I'm making a small app where children can fill preset illustrations with colours. I've succesfully implemented an MS-paint style paint bucket using the flood fill argorithm. However, near the edges of image elements pixels are left unfilled, because the lines are anti-aliased. This is because the current condition on whether to fill is colourAtCurrentPixel == colourToReplace , which doesn't work on the blended pixels at the lines. (the colours are RGB uints) I'd like to add a smoothing/treshold option like in Photoshop and other sophisticated tools, but what's the algorithm to determine the

Drawing with Winforms

半腔热情 提交于 2019-12-01 00:45:42
I want to get myself a bit of WinForm Graphics knowledge, so I'm rewriting my small 2D editor from XNA to WinForm Graphics-only. Now, I made myself a new UserControl for the tileset, but as I've seen, the Paint method is only called at the initialization of the control. Since I want to permanently repaint my control (or at least via MouseOver event to save a bit of performance), I heard the Invalidate() method gets the Control to repaint itself, but that is way too unperformant. Is there any way to let my UserControl paint itself via code, without having these performance-issues? The Paint

Draw Lines perodically

我与影子孤独终老i 提交于 2019-11-30 23:25:24
i am in situation where i want to draw lines one by one with some time period. I tried to do it by using thread.but it didnt work for me. The objective is i've 5 lines. the lines should be drawn one after one with 5seconds delay .Using Thread.sleep(5000) in onDraw() method but all the lines were drawn after 5seconds those were not drawn periodically...how can i draw lines periodically... code snippet:: public class PaintDemoActivity extends Activity { DragView drawView; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate

Get the text height including the font size and set that height

旧时模样 提交于 2019-11-30 21:20:58
i have a text called Hello now i need to apply fontsize for this say 12 or 18 now as soon as we apply font to the text the text size increases. so now i need to get the text height including the font size using paint. i have tried with paint the following: String finalVal ="Hello"; Paint paint = new Paint(); paint.setTextSize(18); paint.setTypeface(Typeface.SANS_SERIF); paint.setColor(Color.BLACK); paint.setStyle(Paint.Style.FILL); Rect result = new Rect(); // Measure the text rectangle to get the height paint.getTextBounds(finalVal, 0, finalVal.length(), result); But its not working , please

Android: is Paint.breakText(…) inaccurate?

↘锁芯ラ 提交于 2019-11-30 21:20:09
I have a View which draws a rectangle with a line of text inside of it. The view uses break text to ensure that no text extends outside of the rectangle; it ignores any text that does. This works fine for some characters, but often Strings made up of 'l's and 'f's extend outside of the rectangle. So, I'm in need of a sanity check here: Is there some obvious flaw in my below code, or is it possible that Paint.breakText(...) is inaccurate? public void onDraw(Canvas canvas) { int MARGIN = 1; int BORDER_WIDTH = 1; Paint p = new Paint(); p.setAntiAlias(true); p.setTextSize(12); p.setTypeface