Hi Steve,

I'm trying to use drawImage() method of Graphics class. I have inserted a 
new label on the form, using the Codename One Designer and I should 
override the paint method of the label to draw the image on it, right? I'm 
having trouble doing that, could you please give me a hint?

Best regards,

David


On Tuesday, March 21, 2017 at 6:15:56 PM UTC-3, Steve Hannah wrote:
>
> Those examples were just to show you 2D drawing on a graphics context.  
> Graphics includes a few drawImage() methods that allow you to draw images.  
> You would use those to draw your images.
>
> Steve
>
> On Tue, Mar 21, 2017 at 2:10 PM, David <[email protected] <javascript:>> 
> wrote:
>
>> Hi Steve,
>>
>> I have checked the clock demo, but the speedometer image I would like to 
>> use is a very complex image made in photoshop (with effects, shadows, etc).
>> I think it will be very hard to draw the same image using Graphics method.
>> Is it possible to import an image from a library using Graphics method 
>> and then rotate and position it?
>>
>> Thanks,
>>
>> David
>>
>> On Tuesday, March 21, 2017 at 5:56:44 PM UTC-3, Steve Hannah wrote:
>>>
>>> I would be tempted to do this in a single component, overriding the 
>>> paint(Graphics) method, and drawing both images directly on Graphics 
>>> context.  This would give you full control over placement, rotation, 
>>> sizing, etc..., of images.
>>>
>>> Check out the clock demo for an example that is similar:
>>> https://www.codenameone.com/demos-ClockDemo.html
>>>
>>> The circle progress library might also give you some ideas:
>>>
>>> https://github.com/chen-fishbein/CN1CircleProgress/blob/master/CN1CircleProgress/src/com/codename1/progress/CircleFilledProgress.java
>>>  
>>> <https://www.google.com/url?q=https%3A%2F%2Fgithub.com%2Fchen-fishbein%2FCN1CircleProgress%2Fblob%2Fmaster%2FCN1CircleProgress%2Fsrc%2Fcom%2Fcodename1%2Fprogress%2FCircleFilledProgress.java&sa=D&sntz=1&usg=AFQjCNHagabFhcLOhtcrUuvMmqhqBc31Qw>
>>>
>>> Steve
>>>
>>>
>>> On Tue, Mar 21, 2017 at 1:30 PM, David <[email protected]> wrote:
>>>
>>>> Hi Steve,
>>>>
>>>> Thanks for the answer.
>>>> Basically, I want to build a speedometer using 2 images (meter image 
>>>> and pointer image). So I used Layered Layout with the pointer image in 
>>>> front of the meter image.
>>>> Since the meter is a half circle type, I have to move the pointer image 
>>>> to the right position and then I can rotate the pointer image to indicate 
>>>> speed.
>>>> I was able to move the pointer image to the right place by changing 
>>>> Padding/Margin or by increasing the height of the pointer image (adding a 
>>>> transparent image below it), but the "blank space" below the speedometer 
>>>> increased and other components below it didn't fit the screen. 
>>>>
>>>> Answers to your questions:
>>>> 1) Other components shouldn't move
>>>> 2) It will be permanent, except the rotation of the pointer
>>>> 3) I would like to animate the pointer movement.
>>>>
>>>> Thanks and regards,
>>>>
>>>> David
>>>>
>>>>
>>>> On Monday, March 20, 2017 at 5:21:43 PM UTC-3, Steve Hannah wrote:
>>>>>
>>>>> It is the job of the layout manager to set size/position of 
>>>>> components.  If you explicitly set the x, y, width, height, of a 
>>>>> component, 
>>>>> your changes will be "wiped out" the next time any of the component's 
>>>>> parents are revalidated/laid out again.
>>>>>
>>>>> You can set the preferredSize (`setPreferredH()`, `setPreferredW()`), 
>>>>> but these methods are marked deprecated to discourage use as it is better 
>>>>> to use a layout manager for this sort of thing.
>>>>>
>>>>> If you can describe a little bit more about what you are trying to do, 
>>>>> then I might be able to offer more specific advice.  Things to think 
>>>>> about:
>>>>>
>>>>> 1. What will happen to the other components in the form when you 
>>>>> resize and reposition the component?  Do they get moved or shifted at all?
>>>>> 2. Is this a new "permanent" state for the form, or is this just a 
>>>>> temporary "highlight" that will be soon removed?
>>>>> 3. Do you want to animate the component on the size change, or just 
>>>>> "jump" to a new position?
>>>>>
>>>>> Steve
>>>>>
>>>>> On Mon, Mar 20, 2017 at 5:55 AM, David <[email protected]> wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I would like to change position of a component dynamically (when a 
>>>>>> button is pressed or after a period of time).
>>>>>> I tried to use setWidth/height/x/y, but every time the screen is 
>>>>>> touched or rotated, the components goes back to its original position 
>>>>>> (defined on the layout manager).
>>>>>>
>>>>>> Is it possible to change a component position different to the 
>>>>>> position set on layout manager?
>>>>>>
>>>>>> Thanks,
>>>>>>
>>>>>> David
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "CodenameOne Discussions" group.
>>>>>> To unsubscribe from this group and stop receiving emails from it, 
>>>>>> send an email to [email protected]
>>>>>> .
>>>>>> Visit this group at 
>>>>>> https://groups.google.com/group/codenameone-discussions.
>>>>>> To view this discussion on the web visit 
>>>>>> https://groups.google.com/d/msgid/codenameone-discussions/bdc3f6bc-09c4-4239-ac78-c862a4a72daa%40googlegroups.com
>>>>>>  
>>>>>> <https://groups.google.com/d/msgid/codenameone-discussions/bdc3f6bc-09c4-4239-ac78-c862a4a72daa%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>>>> .
>>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -- 
>>>>> Steve Hannah
>>>>> Software Developer
>>>>> Codename One
>>>>> http://www.codenameone.com
>>>>>
>>>> -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "CodenameOne Discussions" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send 
>>>> an email to [email protected].
>>>> Visit this group at 
>>>> https://groups.google.com/group/codenameone-discussions.
>>>> To view this discussion on the web visit 
>>>> https://groups.google.com/d/msgid/codenameone-discussions/d622fbbf-e31f-46c8-8d93-1c8bca71a985%40googlegroups.com
>>>>  
>>>> <https://groups.google.com/d/msgid/codenameone-discussions/d622fbbf-e31f-46c8-8d93-1c8bca71a985%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Steve Hannah
>>> Software Developer
>>> Codename One
>>> http://www.codenameone.com
>>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "CodenameOne Discussions" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to [email protected] 
>> <javascript:>.
>> Visit this group at 
>> https://groups.google.com/group/codenameone-discussions.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/codenameone-discussions/f917d26b-243c-40da-92fd-5860b90f5c8d%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/codenameone-discussions/f917d26b-243c-40da-92fd-5860b90f5c8d%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
>
> -- 
> Steve Hannah
> Software Developer
> Codename One
> http://www.codenameone.com
>

-- 
You received this message because you are subscribed to the Google Groups 
"CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/codenameone-discussions/c14b15cb-09e5-44a9-b4b2-b89f70ae4b01%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to