Skip to content

Gui graphics kumar awijeet#9

Open
kumarawijeet wants to merge 47 commits intomasterfrom
GUI_Graphics_Kumar_Awijeet
Open

Gui graphics kumar awijeet#9
kumarawijeet wants to merge 47 commits intomasterfrom
GUI_Graphics_Kumar_Awijeet

Conversation

@kumarawijeet
Copy link
Copy Markdown
Member

No description provided.

}
public void drawTruck(int x3, int y3, double angleToXAxis, Graphics g)
{
//files taken from http://hdimagelib.com/trailer+truck+top+view
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the license they are available with?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                                                                                  No idea about licences available with them. I took it from their website.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Alexander CherednichenkoSent: Sunday 20 March 2016 23:07To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)In gui/src/main/java/kcl/teamIndexZero/traffic/gui/GUI_Primitives.java:
  • }
  • public void drawCurve(int x1, int y1, int x2, int y2, int ctrlx, int ctrly, Graphics g) {
  •    Graphics2D g2 = (Graphics2D) g;
    
  •    QuadCurve2D q = new QuadCurve2D.Float();
    
  •    q.setCurve(x1, y1, ctrlx, ctrly, x2, y2);
    
  •    g2.draw(q);
    
  • }
  • public void drawSingleRoad(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3, Graphics g) {
  •    drawLine(x, y, x1, y1, g);
    
  •    drawLine(x2, y2, x3, y3, g);
    
  • }
  • public void drawTruck(int x3, int y3, double angleToXAxis, Graphics g)
  • {
  •    //files taken from http://hdimagelib.com/trailer+truck+top+view
    

What is the license they are available with?

—You are receiving this because you authored the thread.Reply to this email directly or view it on GitHub

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The image must have a proper license that allows at least academic use. Please check and put the relevant information in the report.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                                                                                  I will try to find that, but if it's not there, can we still use it? There is a © on the second picture but other than that found nothing as to what you are asking.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: EsSent: Monday 21 March 2016 01:11To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)In gui/src/main/java/kcl/teamIndexZero/traffic/gui/GUI_Primitives.java:
  • }
  • public void drawCurve(int x1, int y1, int x2, int y2, int ctrlx, int ctrly, Graphics g) {
  •    Graphics2D g2 = (Graphics2D) g;
    
  •    QuadCurve2D q = new QuadCurve2D.Float();
    
  •    q.setCurve(x1, y1, ctrlx, ctrly, x2, y2);
    
  •    g2.draw(q);
    
  • }
  • public void drawSingleRoad(int x, int y, int x1, int y1, int x2, int y2, int x3, int y3, Graphics g) {
  •    drawLine(x, y, x1, y1, g);
    
  •    drawLine(x2, y2, x3, y3, g);
    
  • }
  • public void drawTruck(int x3, int y3, double angleToXAxis, Graphics g)
  • {
  •    //files taken from http://hdimagelib.com/trailer+truck+top+view
    

The image must have a proper license that allows at least academic use. Please check and put the relevant information in the report.

—You are receiving this because you authored the thread.Reply to this email directly or view it on GitHub

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will try to find that, but if it's not there, can we still use it?
basically no.

As soon as its license is not defined, we can not use it. License is a kind of ephemeral transfer of some rights, either paid or under special circumstances (viral GPL for example). Using something without a license leads to https://en.wikipedia.org/wiki/Copyright_infringement

We all know it is a group project, but doing something like that may lead to a) marks being lowered b) generally is a bad practice. Even if copyright is not stated in the originating document/page by author.

@lexaux
Copy link
Copy Markdown
Collaborator

lexaux commented Mar 21, 2016

@kumarawijeet that is what I'm getting when trying to run your branch. Suggest that image files are not committed/pushed/added to pull request?

java.io.FileNotFoundException: gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg (No such file or directory)
    at java.io.FileInputStream.open0(Native Method)
    at java.io.FileInputStream.open(FileInputStream.java:195)
    at java.io.FileInputStream.<init>(FileInputStream.java:138)
    at java.io.FileInputStream.<init>(FileInputStream.java:93)
    at kcl.teamIndexZero.traffic.gui.GUI_Primitives.drawSmallCar(GUI_Primitives.java:71)
    at kcl.teamIndexZero.traffic.gui.SimulationImageProducer.tick(SimulationImageProducer.java:50)
    at kcl.teamIndexZero.traffic.simulator.Simulator.lambda$start$1(Simulator.java:72)
    at java.util.Arrays$ArrayList.forEach(Arrays.java:3880)
    at kcl.teamIndexZero.traffic.simulator.Simulator.start(Simulator.java:72)
    at kcl.teamIndexZero.traffic.gui.mvc.GuiController.lambda$start$3(GuiController.java:66)
    at java.lang.Thread.run(Thread.java:745)

@kumarawijeet
Copy link
Copy Markdown
Member Author

                                                                                  You are right that's the error you should get when the file is not present, or the file is corrupt. I have saved the file in the sprites folder and then did push request several times. Is there a different pull request for images? If so I didn't know about it. Please let me know that‎ I will push it.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Alexander CherednichenkoSent: Monday 21 March 2016 08:12To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)@kumarawijeet that is what I'm getting when trying to run your branch. Suggest that image files are not committed/pushed/added to pull request? 

java.io.FileNotFoundException: gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at kcl.teamIndexZero.traffic.gui.GUI_Primitives.drawSmallCar(GUI_Primitives.java:71)
at kcl.teamIndexZero.traffic.gui.SimulationImageProducer.tick(SimulationImageProducer.java:50)
at kcl.teamIndexZero.traffic.simulator.Simulator.lambda$start$1(Simulator.java:72)
at java.util.Arrays$ArrayList.forEach(Arrays.java:3880)
at kcl.teamIndexZero.traffic.simulator.Simulator.start(Simulator.java:72)
at kcl.teamIndexZero.traffic.gui.mvc.GuiController.lambda$start$3(GuiController.java:66)
at java.lang.Thread.run(Thread.java:745)

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

@kumarawijeet
Copy link
Copy Markdown
Member Author

2016-03-21
Alex for some reason I am unable to respond to this online, don't know the cause so will reply here. Yes you are right, something is wrong. My pictures in the Explorer are shown in brown in the IntelJ. Don't know why, but like the icons for the buttons it isn't in black. Attaching a screenshot for your kind perusal, hope to get some insight on this. Sent from my BlackBerry 10 smartphone on the EE network. From: Alexander CherednichenkoSent: Monday 21 March 2016 08:12To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)@kumarawijeet that is what I'm getting when trying to run your branch. Suggest that image files are not committed/pushed/added to pull request?

java.io.FileNotFoundException: gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at kcl.teamIndexZero.traffic.gui.GUI_Primitives.drawSmallCar(GUI_Primitives.java:71)
at kcl.teamIndexZero.traffic.gui.SimulationImageProducer.tick(SimulationImageProducer.java:50)
at kcl.teamIndexZero.traffic.simulator.Simulator.lambda$start$1(Simulator.java:72)
at java.util.Arrays$ArrayList.forEach(Arrays.java:3880)
at kcl.teamIndexZero.traffic.simulator.Simulator.start(Simulator.java:72)
at kcl.teamIndexZero.traffic.gui.mvc.GuiController.lambda$start$3(GuiController.java:66)
at java.lang.Thread.run(Thread.java:745)

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

Removed the color change to black, so now the primitive doesn't decide the color of graphics.
The pictures should push but don't know why it's not happening. Any help on this will be great!
@An7ar35
Copy link
Copy Markdown
Member

An7ar35 commented Mar 21, 2016

@kumarawijeet right click and "add to VCS" on the brown files. Then commit/push

@kumarawijeet
Copy link
Copy Markdown
Member Author

                                                                                  Es thanks a lot for that help. Did it, hope it solves the problem that alex was facing. It now show as black, so presume that it's committed.Thanks a lot once again.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: EsSent: Monday 21 March 2016 09:28To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)@kumarawijeet right click and "add to VCS" on the brown files. Then commit/push

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

@kumarawijeet
Copy link
Copy Markdown
Member Author

                                                                                  Alex try to run it now and hope it runs without errors. Just pushed the images.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Kumar AwijeetSent: Monday 21 March 2016 09:16To: Alexander CherednichenkoSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)                                                                                      Alex for some reason I am unable to respond to this online, don't know the cause so will reply here. Yes you are right, something is wrong. My pictures in the Explorer are shown in brown in the IntelJ. Don't know why, but like the icons for the buttons it isn't in black. Attaching a screenshot for your kind perusal, hope to get some insight on this.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Alexander CherednichenkoSent: Monday 21 March 2016 08:12To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)@kumarawijeet that is what I'm getting when trying to run your branch. Suggest that image files are not committed/pushed/added to pull request? 

java.io.FileNotFoundException: gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg (No such file or directory)
at java.io.FileInputStream.open0(Native Method)
at java.io.FileInputStream.open(FileInputStream.java:195)
at java.io.FileInputStream.(FileInputStream.java:138)
at java.io.FileInputStream.(FileInputStream.java:93)
at kcl.teamIndexZero.traffic.gui.GUI_Primitives.drawSmallCar(GUI_Primitives.java:71)
at kcl.teamIndexZero.traffic.gui.SimulationImageProducer.tick(SimulationImageProducer.java:50)
at kcl.teamIndexZero.traffic.simulator.Simulator.lambda$start$1(Simulator.java:72)
at java.util.Arrays$ArrayList.forEach(Arrays.java:3880)
at kcl.teamIndexZero.traffic.simulator.Simulator.start(Simulator.java:72)
at kcl.teamIndexZero.traffic.gui.mvc.GuiController.lambda$start$3(GuiController.java:66)
at java.lang.Thread.run(Thread.java:745)

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

kumarawijeet and others added 7 commits March 21, 2016 09:49
…le is as I got it from the master. Alex hope this solves your problem of maps, if not let me know what more I can do to not destroy the map.
# Conflicts:
#	gui/src/main/java/kcl/teamIndexZero/traffic/gui/SimulationImageProducer.java
#	gui/src/main/java/kcl/teamIndexZero/traffic/gui/SimulatorGui.java
#	gui/src/main/java/kcl/teamIndexZero/traffic/gui/components/MapPanel.java
…taken is some 150 ms.

Have used basic if and else statements to reduce the read time, along with some extra variables.
GUIPrimitivesTest is the test used to check the above results.
TODO add logs for various other exceptions, will go for it tomorrow.
…taken is some 150 ms.

Have used basic if and else statements to reduce the read time, along with some extra variables.
GUIPrimitivesTest is the test used to check the above results.
TODO add logs for various other exceptions, will go for it tomorrow.
newTransformation.rotate(angleToXAxis, x3, y3);
graphics.setTransform(newTransformation);
//InputStream imageStream;
if ((filename == "gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg") && (k == 0)) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You got the point!
It should be faster now.

Instead of using extra variable for the flag, you could do much easier thing: check if the image itself is null or not. I.e.:

public class Primitives {
   ...
   private Image image1 = null;
   ...
   public drawCar(..., filename ) {
      if(image1 == null && filename = "/...car.png" ) {
          ... load image and file
          image1 = ImageIO.read(...)
      } 
      graphics.draw(... image);
}

However, you will need to maintain separate variable for each of the image, and check if filename == one or another. What you could do instead, is use Map<String, Image>, such as HashMap, to use store corresponding pairs of Path --> Image object, and the code would be like:

public class Primitives {
   private Map<String, BufferedImage> imageCache = new HashMap<>();
   ...
   public void drawCar(..., filename) {
       if(!imageCache.containsKey(filename)) {
         // load image, 
         BufferedImage im = ImageIO.read(...)
         imageCache.put(filename, im);
   }
   im = imageCache.get(filename) // we are sure now that it exists, as if it would have not, we would have already loaded it
   graphics.drawImage(im);
}

Does that make sense?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                                                                                  No it makes no sense!!! Lol!!The flag, well your thing is also applicable and yeah we can switch to just checking null value.There is no need to use a variable to check for file names.‎ Just say filename == "address of file". Using a hash map will not be leading to improvement in speed, at least that's what I think. Your comments are not completely understandable on phone, so maybe I am wrong, let me have a look on comp tomorrow, and get back to you.                                                                                                                                                                                                   Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Alexander CherednichenkoSent: Friday 25 March 2016 19:59To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)In gui/src/main/java/kcl/teamIndexZero/traffic/gui/GUI_Primitives.java:
  • }
  • private void drawCar(int x3, int y3, double angleToXAxis, String filename, Graphics g) {
  •    /*
    
  •    Files taken from
    
  •    http://all-free-download.com/free-vector/car-vector-top-view-download.html
    
  •    http://hdimagelib.com/trailer+truck+top+view
    
  •    */
    
  •    Graphics2D graphics = (Graphics2D) g;
    
  •    AffineTransform originalTransform = graphics.getTransform();
    
  •    try {
    
  •        AffineTransform newTransformation = new AffineTransform();
    
  •        newTransformation.rotate(angleToXAxis, x3, y3);
    
  •        graphics.setTransform(newTransformation);
    
  •        //InputStream imageStream;
    
  •        if ((filename == "gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg") && (k == 0)) {
    

You got the point!
It should be faster now.

Instead of using extra variable for the flag, you could do much easier thing: check if the image itself is null or not. I.e.:

public class Primitives {
...
private Image image1 = null;
...
public drawCar(..., filename ) {
if(image1 == null && filename = "/...car.png" ) {
... load image and file
image1 = ImageIO.read(...)
}
graphics.draw(... image);
}

However, you will need to maintain separate variable for each of the image, and check if filename == one or another. What you could do instead, is use Map<String, Image>, such as HashMap, to use store corresponding pairs of Path --> Image object, and the code would be like:

public class Primitives {
private Map<String, BufferedImage> imageCache = new HashMap<>();
...
public void drawCar(..., filename) {
if(!imageCache.containsKey(filename)) {
// load image,
BufferedImage im = ImageIO.read(...)
imageCache.put(filename, im);
}
im = imageCache.get(filename) // we are sure now that it exists, as if it would have not, we would have already loaded it
graphics.drawImage(im);
}

Does that make sense?

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

                                                                                  Alex tried your image == null check, and somehow it takes the time back up, so it's better to leave it with the flags. I think this system works properly with respect to time, let it be that way, let's see other components, like I wanted to check if the flags were actually working, so will create a test for them and check that. Plus we also have to add logging for other exceptions. Also finish the finally branch. So let us see those sections. ‎Moreover, it's not like this code isn't working, so my suggestion is let's wrap it up and finish the rest so that we are able to get it merged and give time to report and other miscellaneous things as well.                                                                                                                                                                                                                                                                                                                                        Sent from my BlackBerry 10 smartphone on the EE network.                                                                                                                                                                                                                From: Alexander CherednichenkoSent: Friday 25 March 2016 19:59To: teamIndexZero/index_zero_trafficsystemReply To: teamIndexZero/index_zero_trafficsystemCc: kumar awijeetSubject: Re: [index_zero_trafficsystem] Gui graphics kumar awijeet (#9)In gui/src/main/java/kcl/teamIndexZero/traffic/gui/GUI_Primitives.java:
  • }
  • private void drawCar(int x3, int y3, double angleToXAxis, String filename, Graphics g) {
  •    /*
    
  •    Files taken from
    
  •    http://all-free-download.com/free-vector/car-vector-top-view-download.html
    
  •    http://hdimagelib.com/trailer+truck+top+view
    
  •    */
    
  •    Graphics2D graphics = (Graphics2D) g;
    
  •    AffineTransform originalTransform = graphics.getTransform();
    
  •    try {
    
  •        AffineTransform newTransformation = new AffineTransform();
    
  •        newTransformation.rotate(angleToXAxis, x3, y3);
    
  •        graphics.setTransform(newTransformation);
    
  •        //InputStream imageStream;
    
  •        if ((filename == "gui/src/main/resources/sprites/bmw_z_top_view_clip_art_18132.jpg") && (k == 0)) {
    

You got the point!
It should be faster now.

Instead of using extra variable for the flag, you could do much easier thing: check if the image itself is null or not. I.e.:

public class Primitives {
...
private Image image1 = null;
...
public drawCar(..., filename ) {
if(image1 == null && filename = "/...car.png" ) {
... load image and file
image1 = ImageIO.read(...)
}
graphics.draw(... image);
}

However, you will need to maintain separate variable for each of the image, and check if filename == one or another. What you could do instead, is use Map<String, Image>, such as HashMap, to use store corresponding pairs of Path --> Image object, and the code would be like:

public class Primitives {
private Map<String, BufferedImage> imageCache = new HashMap<>();
...
public void drawCar(..., filename) {
if(!imageCache.containsKey(filename)) {
// load image,
BufferedImage im = ImageIO.read(...)
imageCache.put(filename, im);
}
im = imageCache.get(filename) // we are sure now that it exists, as if it would have not, we would have already loaded it
graphics.drawImage(im);
}

Does that make sense?

—You are receiving this because you were mentioned.Reply to this email directly or view it on GitHub

Also a few changes in final block to improve functionality.
Also a few changes in final block to improve functionality.
The print statement is removed.
Catch block is still single, with the use of instanceof for distinguishing the exceptions.
The closure of image stream is still done as previously.
The graphics parameter can't be passed somehow, and am unsure about the placement of the function call
The variable GeoPoint is, I think correctly being extracted for x and y coordinates.
The result is not visible on map though, don't know why.
Every call has to be under try and catch for some reason unknown to me.
The end result on the map is the circle of the cars, being removed, but my cars not being there.
The result is not visible on map though, don't know why.
Every call has to be under try and catch for some reason unknown to me.
The end result on the map is the circle of the cars, being removed, but my cars not being there.
Added try and catch to remove errors.
Added log for try and catch in SimulationImageProducer
Changed the graphics to graphics2d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants