Discussion:
Please reply urgent help need it in Taking screenshot in battle.
asherbaig
2008-11-26 14:51:03 UTC
Permalink
Hi, Developers.

Please i need your help in urgent.I want to take the screenshot during
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put it.And
what are code i need to implement it.

Please help !


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
Poh Zhi Hao Jason
2008-11-26 17:43:48 UTC
Permalink
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot during
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put it.And
what are code i need to implement it.
Please help !
You can use the Robot Class
(http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Robot.html) to press
keystrokes in the battle.

Hope that helps! (:


------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2008-11-26 22:10:10 UTC
Permalink
This question cannot be answered or handled quickly.

You could add it as a feature request for Robocode. Then we (Robocode
developers) will spend some time on it and perhaps include this
feature in a comming version of Robocode. :-)

You can add feature requests for Robocode here:

https://sourceforge.net/tracker2/?group_id=37202&atid=419489

It will be faster for us to implement this feature than to explain how
to do it, as it requires a great deal of inside knowledge of how
Robocode is built up etc. And in order to explain how to do it, we
must know exactly what do to it, i.e. actually try to implement it for
real, and then write the documentation about how to do it. All this
takes a great amount of effort. Hence, it's faster for us just to
implement the feature.

However, we have to prioritize our limited time between all the
incoming feature requests etc. beside the changes we want to put into
the game ourselves, e.g. restructuring/refactorings to ease
maintenance and make it possible to implement more features in the future.

Best regards,
- Flemming N. Larsen
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot during
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put it.And
what are code i need to implement it.
Please help !
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
asherbaig
2008-11-27 13:58:04 UTC
Permalink
Hi,
I have done it by working very hard working on MenuBar.java under
robocode.dialog.

And i am able to take snapshot using key crtl-p also.

Now the problem is it takes picture of active window of Robocode game
but now
i want to take picture of only battleview.Is it possible.Because i
just close to it.Here is the code

public void battlePrintActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();

try {
battleManager.pauseBattle();
String path = battleManager.getBattleFilename();
Rectangle screenRect = new Rectangle(robocodeFrame.getBounds());
//get the position of frame
BufferedImage capture = new Robot().createScreenCapture(screenRect);
if (path == null) {
path = saveScreenshotBattleDialog(battleManager.getBattlePath());

}
if (path != null) {

ImageIO.write(capture, "png", new File(path));
}

}
catch(Exception ex)
{
}
finally {
battleManager.resumeBattle();
}
}

public void battleSaveAsActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();

try {
battleManager.pauseBattle();
String path = saveBattleDialog(battleManager.getBattlePath());

if (path != null) {
battleManager.setBattleFilename(path);
battleManager.saveBattleProperties();
}
} finally {
battleManager.resumeBattle();
}
}
Post by flemmingnlarsen
This question cannot be answered or handled quickly.
You could add it as a feature request for Robocode. Then we (Robocode
developers) will spend some time on it and perhaps include this
feature in a comming version of Robocode. :-)
https://sourceforge.net/tracker2/?group_id=37202&atid=419489
It will be faster for us to implement this feature than to explain how
to do it, as it requires a great deal of inside knowledge of how
Robocode is built up etc. And in order to explain how to do it, we
must know exactly what do to it, i.e. actually try to implement it for
real, and then write the documentation about how to do it. All this
takes a great amount of effort. Hence, it's faster for us just to
implement the feature.
However, we have to prioritize our limited time between all the
incoming feature requests etc. beside the changes we want to put into
the game ourselves, e.g. restructuring/refactorings to ease
maintenance and make it possible to implement more features in the future.
Best regards,
- Flemming N. Larsen
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot during
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put it.And
what are code i need to implement it.
Please help !
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2008-11-27 22:17:49 UTC
Permalink
You could use:

manager.getWindowManager().getRobocodeFrame().getBattleView().paint(Graphics)

That is, you e.g. create a BufferedImage with the size of the
BattleView.getBounds(), and call getGraphics() on your BufferedImage,
which you supply as input parameter to the paint(Graphics) above.

Now you have your screen-shot. ;-)

Best regards,
- Flemming
Post by asherbaig
Hi,
I have done it by working very hard working on MenuBar.java under
robocode.dialog.
And i am able to take snapshot using key crtl-p also.
Now the problem is it takes picture of active window of Robocode game
but now
i want to take picture of only battleview.Is it possible.Because i
just close to it.Here is the code
public void battlePrintActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = battleManager.getBattleFilename();
Rectangle screenRect = new Rectangle(robocodeFrame.getBounds());
//get the position of frame
BufferedImage capture = new Robot().createScreenCapture(screenRect);
if (path == null) {
path = saveScreenshotBattleDialog(battleManager.getBattlePath());
}
if (path != null) {
ImageIO.write(capture, "png", new File(path));
}
}
catch(Exception ex)
{
}
finally {
battleManager.resumeBattle();
}
}
public void battleSaveAsActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = saveBattleDialog(battleManager.getBattlePath());
if (path != null) {
battleManager.setBattleFilename(path);
battleManager.saveBattleProperties();
}
} finally {
battleManager.resumeBattle();
}
}
Post by flemmingnlarsen
This question cannot be answered or handled quickly.
You could add it as a feature request for Robocode. Then we (Robocode
developers) will spend some time on it and perhaps include this
feature in a comming version of Robocode. :-)
https://sourceforge.net/tracker2/?group_id=37202&atid=419489
It will be faster for us to implement this feature than to explain how
to do it, as it requires a great deal of inside knowledge of how
Robocode is built up etc. And in order to explain how to do it, we
must know exactly what do to it, i.e. actually try to implement it for
real, and then write the documentation about how to do it. All this
takes a great amount of effort. Hence, it's faster for us just to
implement the feature.
However, we have to prioritize our limited time between all the
incoming feature requests etc. beside the changes we want to put into
the game ourselves, e.g. restructuring/refactorings to ease
maintenance and make it possible to implement more features in the
future.
Post by flemmingnlarsen
Best regards,
- Flemming N. Larsen
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot during
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put it.And
what are code i need to implement it.
Please help !
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
asherbaig
2008-11-28 16:46:46 UTC
Permalink
Hi Developer,

I am not able to undertsand what you try to explain me.Thanks for your
suggestion.

I will gracefully thankful to you please send me the modified code of
what you explain to me.

Once again by heart thanful to you.
manager.getWindowManager().getRobocodeFrame().getBattleView().paint(Graphics)
Post by flemmingnlarsen
That is, you e.g. create a BufferedImage with the size of the
BattleView.getBounds(), and call getGraphics() on your BufferedImage,
which you supply as input parameter to the paint(Graphics) above.
Now you have your screen-shot. ;-)
Best regards,
- Flemming
Post by asherbaig
Hi,
I have done it by working very hard working on MenuBar.java under
robocode.dialog.
And i am able to take snapshot using key crtl-p also.
Now the problem is it takes picture of active window of Robocode game
but now
i want to take picture of only battleview.Is it possible.Because i
just close to it.Here is the code
public void battlePrintActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = battleManager.getBattleFilename();
Rectangle screenRect = new Rectangle(robocodeFrame.getBounds());
//get the position of frame
BufferedImage capture = new
Robot().createScreenCapture(screenRect);
Post by flemmingnlarsen
Post by asherbaig
if (path == null) {
path = saveScreenshotBattleDialog(battleManager.getBattlePath());
}
if (path != null) {
ImageIO.write(capture, "png", new File(path));
}
}
catch(Exception ex)
{
}
finally {
battleManager.resumeBattle();
}
}
public void battleSaveAsActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = saveBattleDialog(battleManager.getBattlePath());
if (path != null) {
battleManager.setBattleFilename(path);
battleManager.saveBattleProperties();
}
} finally {
battleManager.resumeBattle();
}
}
Post by flemmingnlarsen
This question cannot be answered or handled quickly.
You could add it as a feature request for Robocode. Then we (Robocode
developers) will spend some time on it and perhaps include this
feature in a comming version of Robocode. :-)
https://sourceforge.net/tracker2/?group_id=37202&atid=419489
It will be faster for us to implement this feature than to
explain how
Post by flemmingnlarsen
Post by asherbaig
Post by flemmingnlarsen
to do it, as it requires a great deal of inside knowledge of how
Robocode is built up etc. And in order to explain how to do it, we
must know exactly what do to it, i.e. actually try to implement it for
real, and then write the documentation about how to do it. All this
takes a great amount of effort. Hence, it's faster for us just to
implement the feature.
However, we have to prioritize our limited time between all the
incoming feature requests etc. beside the changes we want to put into
the game ourselves, e.g. restructuring/refactorings to ease
maintenance and make it possible to implement more features in the
future.
Post by flemmingnlarsen
Best regards,
- Flemming N. Larsen
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot
during
Post by asherbaig
Post by flemmingnlarsen
Post by asherbaig
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put
it.And
Post by asherbaig
Post by flemmingnlarsen
Post by asherbaig
what are code i need to implement it.
Please help !
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
flemmingnlarsen
2008-11-28 20:49:37 UTC
Permalink
Okay. This is how I think it could be done. But it is a hack!

First make the 'offscreenImage' member public in the BattleView.

Then change your battlePrintActionPerformed() into this one:

public void battlePrintActionPerformed() {
BattleView battleView =
manager.getWindowManager().getRobocodeFrame().getBattleView();

Rectangle size = battleView.getBounds();
BufferedImage capture = new BufferedImage((int)size.getWidth(),
(int)size.getHeight(), BufferedImage.TYPE_INT_RGB);

Graphics2D g = capture.createGraphics();
g.drawImage(battleView.offscreenImage, 0, 0, null);

try {
ImageIO.write(capture, "png", new File("test.png"));
} catch (IOException e) {
e.printStackTrace();
}
}

I think this should work, and that you'll be able to figure out the rest.

I am considering to add this as a feature request, now when it's
almost done anyways. But I will implement it the right way. ;-)
Post by asherbaig
Hi Developer,
I am not able to undertsand what you try to explain me.Thanks for your
suggestion.
I will gracefully thankful to you please send me the modified code of
what you explain to me.
Once again by heart thanful to you.
manager.getWindowManager().getRobocodeFrame().getBattleView().paint(Graphics)
Post by asherbaig
Post by flemmingnlarsen
That is, you e.g. create a BufferedImage with the size of the
BattleView.getBounds(), and call getGraphics() on your BufferedImage,
which you supply as input parameter to the paint(Graphics) above.
Now you have your screen-shot. ;-)
Best regards,
- Flemming
Post by asherbaig
Hi,
I have done it by working very hard working on MenuBar.java under
robocode.dialog.
And i am able to take snapshot using key crtl-p also.
Now the problem is it takes picture of active window of Robocode game
but now
i want to take picture of only battleview.Is it possible.Because i
just close to it.Here is the code
public void battlePrintActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = battleManager.getBattleFilename();
Rectangle screenRect = new Rectangle(robocodeFrame.getBounds());
//get the position of frame
BufferedImage capture = new
Robot().createScreenCapture(screenRect);
Post by flemmingnlarsen
Post by asherbaig
if (path == null) {
path =
saveScreenshotBattleDialog(battleManager.getBattlePath());
Post by asherbaig
Post by flemmingnlarsen
Post by asherbaig
}
if (path != null) {
ImageIO.write(capture, "png", new File(path));
}
}
catch(Exception ex)
{
}
finally {
battleManager.resumeBattle();
}
}
public void battleSaveAsActionPerformed() {
IBattleManager battleManager = manager.getBattleManager();
try {
battleManager.pauseBattle();
String path = saveBattleDialog(battleManager.getBattlePath());
if (path != null) {
battleManager.setBattleFilename(path);
battleManager.saveBattleProperties();
}
} finally {
battleManager.resumeBattle();
}
}
Post by flemmingnlarsen
This question cannot be answered or handled quickly.
You could add it as a feature request for Robocode. Then we
(Robocode
Post by flemmingnlarsen
Post by asherbaig
Post by flemmingnlarsen
developers) will spend some time on it and perhaps include this
feature in a comming version of Robocode. :-)
https://sourceforge.net/tracker2/?group_id=37202&atid=419489
It will be faster for us to implement this feature than to
explain how
Post by flemmingnlarsen
Post by asherbaig
Post by flemmingnlarsen
to do it, as it requires a great deal of inside knowledge of how
Robocode is built up etc. And in order to explain how to do it, we
must know exactly what do to it, i.e. actually try to implement
it for
Post by flemmingnlarsen
Post by asherbaig
Post by flemmingnlarsen
real, and then write the documentation about how to do it. All this
takes a great amount of effort. Hence, it's faster for us just to
implement the feature.
However, we have to prioritize our limited time between all the
incoming feature requests etc. beside the changes we want to put
into
Post by flemmingnlarsen
Post by asherbaig
Post by flemmingnlarsen
the game ourselves, e.g. restructuring/refactorings to ease
maintenance and make it possible to implement more features in the
future.
Post by flemmingnlarsen
Best regards,
- Flemming N. Larsen
Post by asherbaig
Hi, Developers.
Please i need your help in urgent.I want to take the screenshot
during
Post by asherbaig
Post by flemmingnlarsen
Post by asherbaig
the battle using the key "CRTL P".
I need suggestion from you ppl.How to do it and where can i put
it.And
Post by asherbaig
Post by flemmingnlarsen
Post by asherbaig
what are code i need to implement it.
Please help !
------------------------------------

Yahoo! Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/Robocode/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/Robocode/join
(Yahoo! ID required)

<*> To change settings via email:
mailto:Robocode-***@yahoogroups.com
mailto:Robocode-***@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
Robocode-***@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/

Loading...