paint

Java Canvas Drawing

牧云@^-^@ 提交于 2019-12-11 10:02:01
问题 Edit 4: A new formatting for the question BACKGROUND: I have a class, Window, that extends JFrame, In the JFrame I have a canvas. To the canvas I add custom objects. The only purpose of this object(for argumenst sake) is to print a circle with text to the canvas. You can add multiple of these custom components to the canvas. When you add a new custom component it is placed 20 pixels(for now) away from the previous component added to the canvas. PROBLEM: The canvas places the second circle at

Looking for a Post-Constructor Event of a Control

﹥>﹥吖頭↗ 提交于 2019-12-11 09:59:39
问题 I have made a Label subclass and need to initialize a few of its Properties. Some I can set in the constructor, but others are being reset in the designer code of the form, so they must be set after the designer has done its InitializeComponent but before the Paint event runs, which needs them in place. Of course the control should be self-sufficient, so I can't add anything to the form's code. I am using a workaround now: I set a flag bool needsInit = true; which I check in the Paint event.

Snipping tool laggy highlighter

不想你离开。 提交于 2019-12-11 07:35:15
问题 I trying to create a highlighter in C# Winforms. Most of the code i used is here Highlight effect like snipping tool But when i try to draw too fast it lags. Not sure what i'm doing wrong. Here is what i have tried. private void pictureBox1_Paint(object sender, PaintEventArgs e) { Bitmap bmp = (Bitmap)pictureBox1.Image; using (Graphics g = Graphics.FromImage(pictureBox1.Image)) { g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias; g.CompositingQuality = System.Drawing

Minimal way to make a cleanable drawing area

僤鯓⒐⒋嵵緔 提交于 2019-12-11 06:43:38
问题 I got a class with a resizable background. There are paintings over that background(using a paint method and Java2D). How can i delete everything that was drawn every time that the background gets a resize? (To eventually draw again in the correct places) Is there any sort of transform i can do on the already-drawn objects(like scaling to fit the image again)? import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; import java.awt.geom.AffineTransform; import

Drawing two shapes with transparency in Android/Java

别等时光非礼了梦想. 提交于 2019-12-11 05:05:47
问题 I'm drawing two shapes in Android using paint and canvas. I applied transparency to the paint color, but now when the two shapes (same color) intersect the intersecting section comes out darker. Does anyone know how to accomplish this? Here is a quick look at my paint code (which... should be the only object necessary to complete this I imagine). Paint paint = new Paint(); paint.setColor(color); paint.setAntiAlias(true); paint.setStrokeWidth(strokeWidth); paint.setStrokeJoin(Paint.Join.ROUND)

paint canvas android

老子叫甜甜 提交于 2019-12-11 04:52:28
问题 I'm developing in android, and I have to do a Paint for android. I'm using the code below and, when I execute the code, the draw works, but, it seems that there are 2 surfaces to paint, and when you draw in one, the other one disappears. I was looking for the exact error, but cannot find it. Here is the code : import java.util.Random; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android

Painting text on Button - Difference in look

耗尽温柔 提交于 2019-12-11 02:55:30
问题 I have my custom button where I have overridden the OnPaint() and draw the text in it only. On runtime the text looks differently - spacing between chars is lacking. Here is the image of design & runtime of the button : The paint methods is as: protected override void OnPaint(PaintEventArgs pevent) { base.OnPaint(pevent); if (base.ContainsFocus) { // Draw inner dotted rectangle when button is on focus Pen pen = new Pen(Color.Gray, 3); Point p = base.Location; pen.DashStyle = System.Drawing

Vertex labels painting outside of vertex, over scrollbars and onto other components when setLabelsClipped is true

隐身守侯 提交于 2019-12-11 02:47:48
问题 I've been working with JGraph for a while and it appears there is a painting issue when you set label clipping to true: The following boiled-down example shows the problem in a living application that you can mess with: import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionEvent; import javax.swing.AbstractAction; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JTextArea; import

Collision Detection between a Oval and Arc

谁说我不能喝 提交于 2019-12-11 01:44:24
问题 I am writing a simple game, or so it seemed. I created a class that draws a Arc2D (half a circle shape), that same class will repaint the arch as the mouse move. Then I created a new class that draws ovals. This class has some simple mathematics to move the ovals on the screen. The movement of the ovals are not very important. So now that this is done I want to detect if the Oval collides with the arc(half a circle, Only the arc line ) at any point. What I have attempted is making the oval a

Moving Object with Paint Event

若如初见. 提交于 2019-12-10 23:38:40
问题 I have a test tomorrow, and we must use the paint event to redraw our objects, we may not use a timer. As the MSDN says: "The Paint event is raised when the control is redrawn." , but that,occurs for my known, only when the form is minimized, or got invisible and back visible. My code: public partial class Form1 : Form { public Graphics drawArea; public int xPos, yPos; public Form1() { InitializeComponent(); } private void Form1_Paint(object sender, PaintEventArgs e) { drawArea = e.Graphics;