draw

Java - MouseListener Action Event in paintComponent

江枫思渺然 提交于 2019-12-01 23:53:20
Here i have a code which draws a rectangle on the mouseClicked position using the paintComponent.I can get the output message but anything related to graphics and .draw() wont work. Code: import java.awt.*; import java.awt.event.*; import javax.swing.*; public final class testclass extends JFrame { static JPanel p; Timer t; int x = 1; int y = 1; int xspeed = 1; int yspeed = 1; public testclass() { initComponents(); this.setBounds(100, 300, 500, 500); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); t.start(); this.add(p); } public void initComponents() { final ActionListener action = new

Draw a Path as animation on canvas

荒凉一梦 提交于 2019-12-01 11:39:10
I have to ask again because no one answered my question before (my problem is NOT a duplicate of How to draw a path on an Android canvas with animation? ). Please read it carefully and help me, if possible by providing code. The abouve example is unclear for me, and the Path is created on the flow of drawing. This is NOT what I am looking for... I want to draw ONE Path, that already exist in my View class, by drawing its points with time interval, to simulate an animation. How should I modify my onDraw class to archive it? public void onDraw(Canvas canvas) { paint.setStyle(Paint.Style.STROKE);

How to use drawRect to draw in a existing view?

女生的网名这么多〃 提交于 2019-12-01 11:11:51
I'm doing a GPS tracking app. Every time it receives a Latitude/Longitude it converts it to (x,y) coordinates and calls drawRect to draw a line between two (x,y) pairs. However, the drawRect method just clear all the old contents before it draw new thing. How I can make the drawRect to draw new thing on the existing canvas? Thanks in advance here is my viewController.h #import <UIKit/UIKit.h> #import <CoreLocation/CoreLocation.h> @class routetrack; @interface simpleDrawViewController : UIViewController <CLLocationManagerDelegate> { CLLocationManager *locationManager; IBOutlet routetrack

A best way to draw a lot of independent characters in Qt5?

牧云@^-^@ 提交于 2019-12-01 09:13:06
I'm writing an application that displays a lot of text. It's not words and sentences though, it's binary data displayed in CP437 charset. Current form: I'm having a problem though with drawing those characters. I need to draw each character one by one, because later I would like to apply different coloring. Those characters should have a transparent background as well, because later I would like to draw sections and ranges with different colors in the background (to group those characters based on some criteria). The application supports multiple opened files at the same time, but when there

Run function every second Visual C#

我的未来我决定 提交于 2019-12-01 08:02:12
问题 I have problems with timer. I have function in function (draw in func) void func(){ /*...do something ... */ for(){ for() { /*loop*/ draw(A,B, Pen); } /*... do something ...*/ } } This is draw function public void draw1(Point Poc, Point Kra, Pen o) { Graphics g = this.CreateGraphics(); g.DrawLine(o,Poc.X+4, Poc.Y+4,Kra.X+4, Kra.Y+4); g.Dispose(); } I call function 'func' on button click private void button4_Click(object sender, EventArgs e){ func(); } I want to call draw function evry second

How to draw a route between two geopoints on the Android

只谈情不闲聊 提交于 2019-12-01 06:38:36
I have two OverlayItem's on a MapView. How can I draw a route between the two geopoints? This application is contained with source code... It'll solve ur probs. http://www.anddev.org/the_friend_finder_-_mapactivity_using_gps_-_part_i_-_ii-t93.html user278349 This posting J2ME/Android/BlackBerry - driving directions, route between two locations suggests: you must not use the Map Service with any applications for route guidance, including but not limited to turn-by-turn route guidance that is synchronized to the position of a user's sensor-enabled device As such, there is no Android or Google

A best way to draw a lot of independent characters in Qt5?

怎甘沉沦 提交于 2019-12-01 06:06:52
问题 I'm writing an application that displays a lot of text. It's not words and sentences though, it's binary data displayed in CP437 charset. Current form: I'm having a problem though with drawing those characters. I need to draw each character one by one, because later I would like to apply different coloring. Those characters should have a transparent background as well, because later I would like to draw sections and ranges with different colors in the background (to group those characters

How to pause for 5 seconds before drawing the next thing on Android?

谁说胖子不能爱 提交于 2019-12-01 05:35:55
Say I want to draw a line, then wait five seconds, then draw another line. I have a method like this: public void onDraw(Canvas canvas) { int w = canvas.getWidth(); int h = canvas.getHeight(); canvas.drawLine(w/2, 0, w/2, h-1, paint); // PAUSE FIVE SECONDS canvas.drawLine(0, h/2, w-1, h/2, paint); } How do I pause? Don't wait in onDraw method it's called in the UI thread and you'll block it. Use flags to handle which line will be drawn boolean shouldDrawSecondLine = false; public void setDrawSecondLine(boolean flag) { shouldDrawSecondLine = flag; } public void onDraw(Canvas canvas) { int w =

Drawing Graphs (charts) in JSF

冷暖自知 提交于 2019-12-01 05:16:38
问题 How can I draw dynamic graphs in web pages in JSF ? People have suggested Google Chart Api I want something that can work offline 回答1: PrimeFaces have wonderful graph components. You can give them a try. Exadel Fiji also has nice graph components. MyFaces Trinidad is also an option (as indicated by the OP) 回答2: Hey I found an answer to my question after scouring the net. Apache myFaces has a tr:chart component that solves my problem :) 回答3: if you use JSF 2, you can look at flot4jsf2 project.

Draw bitmaps from resources over another

Deadly 提交于 2019-12-01 04:47:22
I have got two bitmaps, background and foreground . How do I draw bitmap foreground on background without using another Canvas? Solution: 1) First create bitmaps from resources with additional option ARGB_8888 BitmapFactory.Options options = new BitmapFactory.Options(); options.inPreferredConfig = Bitmap.Config.ARGB_8888; 2) Declare bitmaps Bitmap background = BitmapFactory.decodeResource(getResources(), R.drawable.background, options); Bitmap foreground = BitmapFactory.decodeResource(getResources(), R.drawable.foreground, options); 3) Inside onDraw() function draw graphics protected void