Changing The Required Pixels Color?

Nov 15, 2014

I would like to draw a rectangle around a certain part of an image.

So I wrote this:

Pixel[] pixels = scene.getPixels();
for( Pixel pixel : pixels)
{
if(pixel >= point.getX() && pixel <= (point.getX()+p2.getWidth())
{
pixel.setGreen(150);
}
}

But the error is giving me incompatible types. I would like to set all the pixels at a certain point up to the dimensions of my rectangle and so on. How would I do that?

View Replies


ADVERTISEMENT

2 Dimensional Array That Represents Color Pixels

Nov 25, 2014

I have this 2 dimensional array that represents color pixels

RGBColor[][] rgbArray1 = new RGBColor[rows][columns] - so each elemnt in this array is a pixel - (red, green, blue)

I wrote a class named RGBImage. represents an image. the constructor of this class takes RGBColor[][] rgbArray1 as an argument and print the image.

My problem is when i try to rotate the image 90 degrees. because the dimentions are changeing. i'm getting ArrayIndexOutOfBounce Exception.

I know i can to this by create a bigger 2 dimensional array and copy the original , but for this assignment i cant do this .

I must use the original one . now i will show the main method that will get things clearer if i didnt explained well enough.

System.out.println("Constructor with RGBColor[][] Array Parameter:");
RGBColor[][] rgbArray1 = new RGBColor[3][4];
for (int i=0; i<rgbArray1.length;i++)
for (int j=0; j<rgbArray1[0].length;j++)
rgbArray1[i][j] = new RGBColor(i,i,i);

[Code] ....

output:

(0,0,0) (0,0,0) (0,0,0) (0,0,0)
(1,1,1) (1,1,1) (1,1,1) (1,1,1)
(2,2,2) (2,2,2) (2,2,2) (2,2,2)

(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)
(2,2,2) (1,1,1) (0,0,0)

This outputs are what i need to accomplish.

View Replies View Related

Swing/AWT/SWT :: Color Is Not Changing

Jan 29, 2015

Color only changes, when resizng frame with mouse, not when clicking.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class SimpleGui1 implements ActionListener {
JFrame frame;
MyDrawnPanel drawnPanel;

[Code] .....

View Replies View Related

Creating UML And Changing Color?

Oct 20, 2014

The Toys of the Future Company has decided to issue a new line of toy robots. While they are not sure exactly what their robots will look like, they do know the functionality that they will all have. All robots will be able to move forward, turn right, turn left, spin and detect an object in front of it via a sensor. The robot will use a touch sensor to determine whether it has hit an object in front of it, such as a wall. The robot will have two, three, or four wheels, but it will only be driven by two of them: a right wheel and a left wheel. Each wheel will be attached to a motor that controls it.

* ^ this is only something to think about
Produce a UML class diagram.

Using UML, describe the objects and classes that will be associated with this new toy. Either hand draw or use an appropriate UML creation tool to generate a UML design document for your Robot class. Create a set of classes that can be used to control the robot.

Develop your new class.

Create a new NetBeans project entitled, "Assignment_8_1" and develop your new class. Now, using the objects and classes that you have written, write a program for your robot that allows it to move in a large square. Allow your robot to run in a big two dimensional array and every time the robot encounters a square in your array, turn that square black.

So here is the code for the moving ball:

package ballapplet;
import java.awt.*;
import java.util.Formatter;
import javax.swing.*;
public class BallApplet extends JPanel {
private static final int BOX_WIDTH = 640;

[Code] ....

I want to know how to change the color of an object, and how to move it in specific directions.

View Replies View Related

Changing Color Of Frame Of Windows

May 2, 2014

In the image, the color of the frame of the window/JFrame is black. My question is that can we set the color of this frame, or is it just provided by the operating system and whatever color is default color of windows in an operating system will appear in our application?

I am talking about the frame, the boundary in the JFrame container which contains the close, maximize, and minimize buttons.

View Replies View Related

Swing/AWT/SWT :: Changing Rectangle Color With MouseListener

Mar 2, 2014

I'm trying to build a program which sets a fill color for a rectangle. Each time the mouse is clicked the fill color changes according to the position of the mouse's X and Y. I succeeded to create a JFrame with a changing background according to the Mouse's position, but I can't seem to change the color of the rectangle (defined in MyPanel class).

This is the current code,

import java.awt.*;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.SwingUtilities;
import javax.swing.JFrame;

[Code]...

View Replies View Related

Swing/AWT/SWT :: Changing Color Of JList Item

Oct 23, 2014

is there a good way to change the color of a JList item that isn't selected? I'm throwing my hand at building a client/server chat app and on the client side, I need to highlight the name of the person (which is in a JList) who has sent a message to the client GUI.

View Replies View Related

Constantly Changing Color Of Areas Of A World Map

Oct 7, 2014

I am trying to create a virus simulation program. The program is supposed to just be a map of the world where the user can click any country in the world to specify where they want their virus to start, specify how transmittable the virus is, and be able to see how the virus spreads through the world by seeing a change in color throughout the world,

I want the world map to initially start out with a very light yellow, and as areas of the world slowly start to get more and more infected by the virus, I want those areas on the map to start changing to a very dark red (going from a light yellow, through shades of orange and red, to dark red).

So, the main idea of this is to have a program that displays an image where certain parts of the image will slowly change color during the runtime of the program. I obviously know how to change colors of certain parts of a window or even an image, and how to even start this.

View Replies View Related

JavaFX 2.0 :: Chart Axis Changing Color

Mar 20, 2015

I'm struggling to change the colour of the X and Y axis. I can change the colour of the ticks and the tick labels in CSS... But not the axis themselves.

View Replies View Related

Java Eclipse - Changing Color Output Elements

Oct 29, 2014

how to change the color of an output element in Eclipse? Can't seem to find it anywhere on the internet.For example, a response to my question 'What color do you want?' could be 'red'. I added an if-statement, which states if input = red, start using a red colored 'X' as string for further output.How do I obtain the color red for my X?? Or isn't it possible changing the color of output elements?

View Replies View Related

Constantly Changing Color Of World Map Image In Java

Oct 7, 2014

I am trying to create a virus simulation program. The program is supposed to just be a map of the world where the user can click any country in the world to specify where they want their virus to start, specify how transmittable the virus is, and be able to see how the virus spreads through the world by seeing a change in color throughout the world,

I want the world map to initially start out with a very light yellow, and as areas of the world slowly start to get more and more infected by the virus, I want those areas on the map to start changing to a very dark red (going from a light yellow, through shades of orange and red, to dark red).

So, the main idea of this is to have a program that displays an image where certain parts of the image will slowly change color during the runtime of the program. I obviously know how to change colors of certain parts of a window or even an image, but this is very very detailed and advanced but how to even start this.

View Replies View Related

Swing/AWT/SWT :: Changing Color Of Jtable Base On A Row Of Cell Value In One Column

Feb 10, 2014

My code is

Double qty = 0.0;
for ( int i = 0; i < ingTable.getRowCount(); i++){
qty = (Double) ingTable.getValueAt(i,2);
if( qty < 30.0){
ingTable.setBackground(Color.red);
} else {
ingTable.setBackground(Color.white);
}
}

View Replies View Related

JavaFX 2.0 :: Setting Background Color For Layout - Fill / Color On OS X

Jun 10, 2014

No problem setting background color for layouts, e.g. bdrPn.setBackground(new Background((new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY))));
 
But neither of the following are working for me, running JavaFX 8 on latest OS-X
 
scene = new Scene(bdrPn, winW, winH, Color.BLACK);
scene.setFill(Color.BLACK); 
scene.setFill() worked fine for previous versions of JavaFX.

View Replies View Related

Can't Get Background Color To Change From Basic Gray Color

Oct 20, 2014

I've just started working on a program and i'm already having difficulties with the program. I can't get the background color to change from the basic gray color. Maybe you can tell me what i'm doing wrong.

import javax.swing.JFrame;
import javax.swing.WindowConstants;
import java.awt.*;
import java.lang.Object;
import java.awt.Color;
public class FrameDemo{
public static void main(String args[]){
Toolkit toolkit = Toolkit.getDefaultToolkit ();

[Code]...

also if theres any way to shorten up what I have there, that would be great.

View Replies View Related

GUI Bars - Increment Height By About 10 Pixels

Nov 12, 2014

So I'm trying to make a bar graph, each bar will increment the height by about 10 pixels. To do this, I'm making an array of bars. For some reason, using fillrect I cannot not increase the size more than 10 by 10, if I do, it will only show the 10 by 10. I want the bars to increase in height by 10 each time.

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
public class AssortedAssortmentsOfSorts extends JFrame

[Code] .....

View Replies View Related

Image Processing - Array Of Pixels

Feb 13, 2015

I am trying to process an array of pixels, checking each within a 5*5 mask. Ive declared my mask as a 2d array and get the pixel values within a nested for loop. Im getting an ArrayIndexOutOfBoundsException at the line:

mask[0][4] = dsIm.red[i-1][j+3];

Have I declared my mask wrong for a 5*5 mask. Is my logic wrong?

I won't give all the code, but basically Im trying to check all 25 pixel values within the mask:

int [][] mask = new int[5][5];
System.out.println("We are in the method just written");
//loop one loop
for(int i = 1; i <= h-2; i++)
{
for(int j = 1; j<=w-2; j++)

[Code] .....

View Replies View Related

Input String Color Name And Set It To Color Object

Nov 24, 2009

If I want to read from file the word "red" And then the following is not the right way like in the code ,, How to set the Color name

File inputFile = new File ("C:\input.txt");
Scanner scan = new Scanner (inputFile);
String RedColor=scan.nextLine();
Color backColor = new Color(redColor);

View Replies View Related

Rendering Images Of Type BufferedImage - Pixels Are Not Consistent In Size

Jun 26, 2014

As implied by the title, when I am rendering images of the type "BufferedImage" unto a Swing application, the images' pixels are not consistent in size. Some might be larger than other, and some might be smaller than other.

Here is a screenshot of what I am talking about (you might need to zoom in a bit because the image is so small): [URL] ....

And here is also some code for you. The images are actually from a sprite sheet, which I first load in its entirety and then split up in an array.

Java Code:

public static BufferedImage sprites[];
...
public void loadSprites(){
try{
BufferedImage bigImage = ImageIO.read(new File("SOURCE/BLA/BLA/THIS/IS/ACTUALLY/NOT/THE/REAL/SOURCE/IN/CASE/YOU'RE/WONDERING/I/JUST/DON'T/WANT/YOU/TO/FIND/ME/AND/RAPE/ME"));
sprites = new BufferedImage[16 * 16];

[Code] ....

So, how do I make the pixels equally small?

View Replies View Related

Swing/AWT/SWT :: Double Drawing Pixels When Manipulating DataBuffer Of BufferedImage

Feb 9, 2014

I've been working my way through a tutorial to build a simple 2D tile-based engine that also allows the code to manipulate the colour of pixels on the screen based on a monochrome map read from a file. I've got the code right line for line, but I seem to have a bug when it comes to draw to the screen! At regular intervals, despite what is held in the pixel array of ints (which I have confirmed to be correct when debugging), I get the same row of pixels being draw twice in a row. I figured there was some loop issue somewhere, but after attempting to debug this for some time, I haven't come up with the answer.

Original tilesheet:As rendered:

Game.java:
package igg.engine.game;
import igg.engine.game.gfx.Screen;
import igg.engine.game.gfx.SpriteSheet;
import java.awt.BorderLayout;
import java.awt.Canvas;
import java.awt.Color;

[Code] ....

View Replies View Related

Code Required In Form Of Key Values

May 20, 2014

Suppose I have the file in a particular directory with the below conntent starts with the below line -

5/15/2014 2:07:36 PM : 10 - 10 : *** Loading XML file DSH_000001_pos.xml ***

After that the content is shown below.

5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for PERIOD DSH - TRDBOOK +NSCCL :INR - HOUS - (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for Exchange Complex NSCCL PERIOD Exchange Complex (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for Combined Commodity ANDHRABANK - ANDHRABANK PERIOD Combined Commodity (INR).
5/15/2014 2:07:36 PM : 10 - 30 : Loading positions for PERIOD DSH - CFDTRADING +ASXCC :GBP - HOUS - (GBP).
5/15/2014 2:07:36 PM : 20 - 30 : For <ecPort> ASXCC can't find required associated object <clearingOrg>

[code]....

View Replies View Related

SOAP Output Required In XML Format

Mar 21, 2014

Using the concept of web service (SOAP), I need to have a web service running. The client page will pass an ID to the web service and in return the service will return some values retrieved from the database based on the ID passed, as output. The output so fetched has to be in XML format.

View Replies View Related

Unexpected Type - A Returned Variable Required

Apr 2, 2014

I'm making a Hangman program for Java, here's my code:

import java.util.Scanner;
public class Hangman {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String answerWord = WordList.getWord();

[Code] .....

The Compiler gives me this only error:

Hangman.java:39: error: unexpected type
displayWord.charAt(i)=userInput.charAt(0);
^
required: variable
found: value

I understand that charAt returns i as a value and not a variable. What do I use to return a variable as I intended?

View Replies View Related

Use Switch Or If / Else Statement To Filter Out Data Not Required For App

Feb 21, 2015

I'm using jsoup to parse a calendar page.

I want to use a switch or if/else statement to filter out the data I don't need for the app. This is by no means anything more than a draft because java is easier to work with than android.

Element table = doc.getElementById("launch_calendar");
Iterator<Element> iterate = table.select("td").iterator();
if(iterate.hasNext()){
for(iterate.hasNext();;){
counter++;

[Code] ....

View Replies View Related

Servlets :: Submitting Images - Restful API Required?

Mar 8, 2014

I am working on an android application that submits images to a servlet, is there any need for me to use restful api ??

View Replies View Related

Swing/AWT/SWT :: Why Negative Offset Of Y Coordinate Required In Program

Feb 3, 2015

import java.awt.*;
import java.awt.image.*;
import java.awt.event.*;
import javax.swing.*;
import java.net.*;
/**
An applet that shows a rotating globe.

[Code] ....

View Replies View Related

Swing/AWT/SWT :: Can't Get Gridbag Layout Components To Display As Required

May 4, 2014

I have quite a specific view for how I want my components layed out. No matter what I try I can get them to display how I want! I'm using three JPanels. There's a main panel that goes inside the tabbed pane. This main panel contains two other panels. The First panel is a gridbaglayout panel, with labels on the left column, and components on the right column. The second panel is underneath the second, and contains a label, and a button beneath it. THis uses a basic box layout, with one component per line. The label doesn't always appear (depends if a component is changed). With everything showing, this is how it looks so far:

However, I want the Labels on the left of the pane. The right hand column should be aligned horizontally and have more space from the labels. Ideally I'd like a gap between the last label/checkbox and the Note label.

This is my current code for the panel/s inside the tabbed pane window.

videoPanel = new JPanel();
applyVidBtn = new JButton("Apply Settings");
applyVidBtn.setVisible(false);
warningLbl = new JLabel("Note. Applying these settings causes a program restart.");
warningLbl.setVisible(false);

[Code] .....

View Replies View Related







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