Swing/AWT/SWT :: AffineTransform - Rotation Is Being Ignored When Set Transform

May 31, 2014

I'm experimenting with AffineTransform, Basically I've created just a simple test GUI to see how the code works and all that. Anyway, there are two buttons which turn an image left and right and a third button with moves the image to the right (East). When you first run the program the image is facing down (South). Now to turn left or right I'm using an Affine Transform and the rotate method. That works fine. The issue is when I move the image to the right, it ignore whatever rotation I previously I made (from turn left and right buttons). Therefore when I click to move the image, it faces down again even if it was facing left or up or right before I moved it. It will always be facing down. How do I get it to keep the rotation and just move? Btw I'm using the setTranslate method to move the image.

Below is my code.

Images.java
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;
import javax.imageio.ImageIO;
public class Images {
static BufferedImage Icon, Rover;

[Code] ....

View Replies


ADVERTISEMENT

Swing/AWT/SWT :: AffineTransform Making Image To Move

Aug 5, 2009

I've been trying to make an image rotate in a panel. I did it. But also i want the image to make a translation.

Here is the code i tryed at paintComponent() :

//////////////////////////

Graphics2D g2 = (Graphics2D) g ;
AffineTransform at = new AffineTransform() ;
// at.rotate ( angle in radians ) ;
at.rotate( this.getAngulo(1, 1) ) ;
g2.drawImage(imgemFlecha, at, this);
/////////////////////////////

I cant change image x,y doing this drawImage(). I want to make that change.

View Replies View Related

Graphics Rotation In Swing

Feb 3, 2014

How to rotate a shape in Swing? The only thing I found was something involving this, but I have not seen something like this before:

Java Code : Graphics2D g2d = (Graphics2D)g; mh_sh_highlight_all('java');

I see this is an object reference, but what is on the right side? Does not seem like a method, as it would not equal a method nor would the parentheses be on the left. Why are parentheses there? Disregarding the above code, I would like to know how to rotate without Graphics 2d

Also, with G2D you it will not allow for setting x coords

View Replies View Related

Swing/AWT/SWT :: 2D Spaceship Game - Image Rotation And Position

Aug 29, 2014

I'm attempting to create a 2D spaceship game from scratch. My problem is that I feel like the way Im rotating images is awkward and just wrong. I believe what I'm doing in the following code is loading an image into a JPanel and rotating the image and moving the JPanel.

The code is unrefined and only partial, but it show how I am manipulating images.

import java.util.*;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.awt.geom.AffineTransform;
import javax.swing.*;
import java.lang.Math.*;
import java.io.*;
import javax.imageio.*;

[Code] .....

What seems so awkward is that I have to create a new JPanel for every image, I would think there is a better way but I don't know. I have tried to get one image on top of an other with the JPanels to no avail. That said I haven't put much time into trying to get that to work. I want to know if I should continue my attempt with JPanels or to pursue a different method.

View Replies View Related

Fast Fourier Transform Of Images

Jun 4, 2015

I have a problem that is associated with Fast Fourier Transform of an image. I've made an application with some filters for an images. It's a program with JLabels for displaying images before and after filtration and JButtons for filters. So, my problem is with FFT for an image, i've seen examples for that transformation, but i really don't know how to use that in my program.

View Replies View Related

Image Rotation And Alignment

Mar 22, 2014

My problem in order to align and and rotation for image?

View Replies View Related

2D Circle Texture Rotation?

Jan 11, 2015

So I have this randomly generated set of tiles that is wrapped in a circle and I'm not really sure how to scroll it around the circle. Basically it's a side-view planet that is in 2D and needs to be wrapped and moving at a controllable rate to give the illusion of planet rotation. What to do to the x and y to make it scroll around. I want every tile except the water tiles to move from left to right and then wrap around the circle. Here's what a planet looks like: [URL] ....

Java Code:

for (int x = 0; x < planet1.length; x++)
{
for (int y = 0; y < planet1[0].length; y++)
{
if (planet1[x][y] == 1 || planet1[x][y] == 2)
{
g.drawImage(water, x * 32, y * 32);

[Code] ....

View Replies View Related

JavaFX 2.0 :: Invalid Transform On Shape After Creation

Jan 21, 2015

I am working on a UI in JavaFX and create several instances of a custom control class. The control consists of a Pane which wraps several other containers, one of which contains a Circle shape.
 
At one point, I instance this control and access the Circle shape directly. I transform it's center coordinates (which are always {0.0, 0.0} ) to Scene coordinates.  The problem is, the transformation always yields coordinates that correspond to the upper left corner of the control's root pane.
 
In other words, it's as if the Circle is positioned at the upper left corner of the custom control (when, in fact, it's positioned near the lower right corner).
 
I have other instanced controls already in the scene, and they do not have this issue - converting the Circle's coordinates to scene coordinates works as it should.
 
It seems obvious that I'm accessing the Circle too soon - that perhaps the scene graph hasn't been fully traversed for the control and the Circle's position within the control's hierarchy hasn't been updated.  I've verified that my attempt to access the Circle's center coordinates occurs after the control's initialize() method is executed, so how to ensure the control's scene graph has been fully updated before I try to manipulate the control...

View Replies View Related

Program That Will Accept Values And Transform Scores To Grade

Aug 26, 2014

I was trying to write a program that will accept values and transform the scores to grade. Like 70 and above will be given A from 60 to 69 is B, from 50 to 59 is C, from 40 to 49 is D and below 40 is F. I have defined the variables, for the textfield, am confused on how make this hapen on just a click of the comand botton.

View Replies View Related

How To Transform Code To Save Room Booking Into TXT File

Sep 24, 2014

I am doing the home work to create a mini hotel reservation system which should be able to write the data into .txt file.

case study:

1. Have 2 different types of room (1- Suite 2- Deluxe)

2. Room Rate (Suite - $500per night, Deluxe - $300per night)

3. Both rooms can accomodate 2adults and 2childs

4. Checkin time: 2pm, Checkout 11am

5. Room status = occupied once guest checkin, Room status = vacant once guest checkout

6.For checking require (ID,Full Name,Address,Nationality,Flight no/Vehicle Reg no,number of people,check-in date, check-out-date,payment detail

7.Front desk search the vacant room to be assigned to the guest

Functions:

1. View all rooms
2. Add Customer to a room
3. Display available room
4. Delete customer from a room
5. Find room from customer name
6. Exit

Files:

One file use to store room info. (to be retrieved by program)

One file use to store rate info. (to be retrieve by program)

One file use to store the booking details (to be created and write by the program).

Currently I have write a program but only compiling and display the output to the console. How to modify my code below to be able to save to the .txt file

Here is the code:

import java.util.*;
import java.io.*;
class Customer {
private String name;
private int room;
public void setName(String name) {
this.name=name;

[code]...

View Replies View Related

JavaFX 2.0 :: Panel Effect - Rotation Along Its Y Axis

Dec 14, 2014

I have a UI widget, like a table view for example, displaying real-time data. This table can be configured - so it has many properties. The way I would like to do so, is to have a small 'configure button', once clicked, would rotate the entire table along its y axis, and display another panel with checkboxes etc... So effectively, the hidden properties panel is revealed by rotation.

View Replies View Related

JavaFX 2.0 :: Image Overlay Rotation Interpolation Error

Jun 12, 2015

I'd like to draw an overlay on an image. The overlay is also an image with a black background and a white foreground. Now the white pixels should be drawn on the image in red. This is possible with the code I posted below. However, the problem arises when rotating the stencil (overlay). I get some interpolation errors from the rotation on the boundaries. I tried to clip them with setClip(), but this turns the background from transparent to white. How to remove those spots? Or maybe a completely other idea of achieving an overlay on the image? I'm aware of the pixelreader and iterating through the stencils pixels and draw the respective pixels as rectangles on a Canvas' graphicContext. However, this was extremely slow, compared to the code I posted below (although it doesn't work with rotations).

Here I surrounded the errors:
 
The image:
 
The stencil:
 
And here is the code:
 
import javafx.application.Application; 
import javafx.geometry.Insets;
import javafx.scene.*;
import javafx.scene.effect.BlendMode;
import javafx.scene.image.*;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;

[Code] .....

View Replies View Related

JavaFX 2.0 :: 3D Sphere To Represent Each Single Point - Rotation Lagging With Large Number Of Points

May 22, 2014

We are doing a visualisation tool for point cloud research project. We use 3d sphere to represent each single point and when we have large number of points to display (~40,000), the rotation becomes very lagging.
 
What we have tried:

set JVM flag -Djavafx.animation.fullspeed=true, this worked a bit, but not significant.set JVM flag -Djavafx.autoproxy.disable=true, this did not work.

set Cache to true and CacheHint to Cache.SPEED, this did not make much difference.create another thread to do the rotation, and sync back after calculation, this did not work neither.

View Replies View Related

Transform Simple Date Format - Get Calendar Date

Apr 4, 2015

Given a Date such as this sampleDate (120, 08, 02), does SimpleDateFormat transform this given sampleDate using (sampleDate.get(Calendar.DATE)) ?

Issue is that without the SimpleDateFormat the days are outputting correctly but starting with 1,2,3,4 etc and when I apply the SimpleDateFormat to the above Date I only get 01,01,01 etc...

I am looking for 01,02,03 etc...

View Replies View Related

How To Use JAXB - Transform TXT Files Into XML Files

Mar 10, 2015

I need to transformation the txt files into xml files, but each row txt files don't have same elements, for example the first book is composite one author

<books>
<book>Title</book>
<price>price</price>
<author>Author</author>
</books>

but the second book is composite two author

<books>
<book>Title</book>
<price>price</price>
<author>Author</author>
<author>Author2</author>
</books>

I would have the xml files with the number of authors variables, I can use JAXB for my problem?or not?

View Replies View Related

Swing/AWT/SWT :: Add Progressbar To Project For Listening Swing Worker Updates?

Feb 16, 2014

I have a problem with progress bar implementation to my project. Let me explain it;

I have Jframe named GUI. Filled with 2 datechooser combo box and 1 Buton.

And i have a Swingworker class named "MySwingWorker" for my long running task just like this;

package exampleproject;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.logging.Level;
import java.util.logging.Logger;

[code]....

Just i want add a progress bar for listening MySwingWorker's setProgress updates. When buton clicked swingworker should executed and progress bar should come to screen. I read many articles about that but not understand correctly. Because i am beginner in JAVA.

Question1: Should i (create new class) or (implement to current gui or swingworker class) for progressbar?

Question2: Should i fired progress bar first and execute swingworker from progressbar class? or should i execute swingworker first and fired progress bar later and how?

View Replies View Related

Swing/AWT/SWT :: Factory Design Pattern With Swing JDialog

Jul 26, 2014

Is it a good idea to use the factory design pattern for say if I needed to create four different JDialogs for the same parent frame?

factory design interface
package client;
public interface Dialog {
void getInstanceOf ();
void initComponents ();
}

One of the four JDialog class would look something like this without the comments.

package client;
import javax.swing.JDialog;
@SuppressWarnings("serial")
public class AddCustomerDialog extends JDialog implements Dialog{
public AddCustomerDialog () {
//Some stuff goes here to set the settings for JDialog instance

[code]....

Of course you would have your factory class

View Replies View Related

Swing/AWT/SWT :: Runtime Localization Of Swing Application

Mar 19, 2014

I would like to be able to change the locale in my Swing application at runtime and have all the text elements on the GUI update themselves with localized text from a ResourceBundle of the new locale.If there a simple way of achieving this without having to create an event model for all GUI pages?

View Replies View Related

Swing/AWT/SWT :: Can Use Swing In Web App

Apr 19, 2014

can we create web applications using swings? if yes how to create web app using swing?

View Replies View Related

Swing/AWT/SWT :: How To Add Jcolumn

Jan 17, 2015

I have created a jtable with two columns so I need add checkboxes dynamically in to the first column.Bıt I couldn find something like add.How can do this.This is what I have so far

public CheckBoxes(){
table=new JTable(new TableModels());
TableColumnModel columnModel = null;
JCheckBox box;
for (int i = 0; i <2; i++) {

[Code] ....

View Replies View Related

Swing/AWT/SWT :: How To Add In A JCheckBox

Dec 20, 2014

I've almost finished building an Editor in Java, but i'm a bit stuck on creating a JCheckBox that saves your credentials (as in password only) . I would like it to be on a JPanel under the password input box and above the Login and Register buttons.

Code:
Login.java (Main class for this problem)

[URL] ....

The main thing here is using GridLayout, which is what im currently working with but can't seem to get it under the password input box.. check: [URL] ....

View Replies View Related

Add Combobox To Swing

Mar 17, 2014

How to add combo box to swing ....

View Replies View Related

Swing/AWT/SWT :: Open GUI On Top Of Another GUI

Feb 12, 2014

how to open a GUI on top of another GUI? I have built a GUI and have a button that when pressed I want to open a new GUI which is another java application within the project, it seems pretty straight forward and I just need to insert 'new [name of application]()'

Button btnEdit = new Button(shell, SWT.NONE);
btnEdit.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
new edit();
}
});
btnEdit.setBounds(76, 10, 75, 25);
btnEdit.setText("Edit");

View Replies View Related

Best Way To Run A Swing Application On The Web?

Sep 13, 2014

What is the best way to run a Swing application on the web? Should I convert it to an applet or do something else?

View Replies View Related

Swing GUI Programming

Jan 6, 2014

I find myself asking these two questions because I see them as relating. First question is; I always write

Java Code: f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); mh_sh_highlight_all('java');
(where f is a JFrame object)

to set the close for the JFrame. What I don't get about this is what is going on in the parenthesis. I looked in the Java Documentation, and it says an int goes inside. In that case, I don't really get what the word JFrame is doing there. Overall, please explain what is inside the parenthesis of that line and why it has to be there.The second question is a generic question. I notice a lot of times an object will be created, and as its parameter, you will have to instantiate an object. an example would be

Java Code: Class f = new Class(new Object) mh_sh_highlight_all('java');

What does it mean when an object gets created inside of a new object? Why is putting Java Code: new Object mh_sh_highlight_all('java');
ever necessary when concerning the two parenthesis?

View Replies View Related

Swing/AWT/SWT :: How To Add JMenuBar

Jan 16, 2015

I am trying to add a JMenuBar to this program with just one dropdown to select one option but I am getting an error with the setJMenuBar(menuBar); line as it does not extend JFram. How I would add a menu to this program another way.

public class Calculator extends JPanel implements ActionListener{
private static final long serialVersionUID = 1L;
JMenuBar menuBar = new JMenuBar();
JMenu noteMenu = new JMenu("Note");
JMenuItem newNote = new JMenuItem("New Note");
public static final int WIDTH = 350;
public static final int HEIGHT = 560;

[Code] ....

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved