New to FW - how to resize a simple vector graphic?
I'm brand new to Fireworks and just downloaded the trial version of CS5 a couple hours ago. I hunted around and watched some of the tutorials but haven't found an answer to my question so I'll take the easy way and ask here!
I've got an existing png file I need to modify to use as elements to a website I'm building in Dreamweaver. There are a couple vector based boxes that I need to change the dimensions of. They've got rounded corners and a stroke border. Question: How do I simply lengthen the width of these boxes without changing the shape of the corners?
Jim, double clicking on the objects didn't work for me. Here's what I had to do:
1. select the object w/ black pointer
2. go to Modify > Symbol > Convert to Symbol
3. specify as graphic and enable 9-slice
4. change the width numerically in the properties inspector.
Thanks,
John
Similar Messages
-
How to copy and paste vector graphics
I have a program that draws curves and I would like to copy and paste them as a path into Adobe Photoshop.
I am using the Clipboard class (Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard()), but I
do not know what string I should use for the StringSelection argument in the setContents method. I tried the
string that describes my curves in PostScript.
But that didn't even work for pasting into Adobe Illustrator, although Illustrator is capable of opening
a PostScript file. (However Photoshop only opens a PostScript file as a bitmap, not as a path.)
With Illustrator, instead of pasting the curves, it just pasted the PostScript text.
Please help.
Thanks.For me, freehep is the fifth hit when googling "java vector graphics library". But of course I don't get to "[Access hidden information|http://www.copernic.com/en/products/agent/index.html]" without paying up :).
For a simpler way: since you already say you can save to postscript, make a temporary ps file and export it in a file list (keywords "java drag and drop files"). Perhaps Illustrator then opens the file and the user can copy/paste it there. Otherwise you have to figure out what Illustrator expects on the clipboard and put it there in the same format.
Another option might be to use some com wrapper to talk to Illustrator directly (but probably need a commercial com wrapper for that). -
How can I make ANY vector graphics with graphics2D and save on clipboard?
I am at my wits end here, and need some help. Simply put, I have a program that creates a basic x-y graph, drawn in a jpanel. I want to create the graph as a vector (emf, eps, svg, I don't care anymore, any of them would be good). But, all I get is a jpg or bitmap.
I tried using the infamous FreeHEP programs, but it won't recognize the output as anything but "image" which means bitmap/jpg.
The user enters x/y data, clicks a button, which crreates a jpanel thusly:
public class GraphMaker extends JPanel {
static BufferedImage image = new BufferedImage(600, 500, BufferedImage.TYPE_INT_ARGB);
GraphMaker(double[] xVals, double[] yVals, double[] sems){
setPreferredSize(new Dimension (600,500));
symSize = 10;
XminV = 0;
XmaxV = 0;
// code here just converts input x and y's to pixel coordinates, spacing of ticks, etc...
for (int i =0;i < ArLn; i++){
gX[i] = xO + (gX[i] * xRat);
gX[i] -= xStart;
gY[i] = gY[i] * yRat;
gY[i] = yEnd - gY;
semVal[i] = semVal[i]*yRat;
Ymin = yEnd - (Ymin*yRat);
Ymax = yEnd - (Ymax*yRat);
BufferedImage anImage = new BufferedImage(600, 500, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2 = anImage.createGraphics();
g2.setBackground(white);
g2.setColor( Color.WHITE );
g2.fillRect(0,0,600,500);
g2.setStroke(stroke);
// here I use the values to draw lines and circles - nothing spectacular:
g2.setPaint(Color.blue);
int ii = 0;
for ( int j = 0; j < ArLn[ii]; j++ ) {
g2.fill(new Ellipse2D.Float(LgX[ii][j] - symOffst, gY[ii][j]-symOffst, symSize,symSize));
g2.draw(new Line2D.Float(LgX[ii][j],(gY[ii][j]-semVal[ii][j]),LgX[ii][j],(gY[ii][j]+semVal[ii][j])));
g2.draw(new Line2D.Float(LgX[ii][j]-2.0f,(gY[ii][j]-semVal[ii][j]),LgX[ii][j]+2.0f,(gY[ii][j]-semVal[ii][j])));
g2.draw(new Line2D.Float(LgX[ii][j]-2.0f,(gY[ii][j]+semVal[ii][j]),LgX[ii][j]+2.0f,(gY[ii][j]+semVal[ii][j])));
g2.draw(new Line2D.Float(xLoVal[ii],yLoVal[ii],xHiVal[ii],yHiVal[ii]));
image = anImage;
And, when the user clicks on the "copy" button, invokes this:
public class Freep implements Transferable, ClipboardOwner {
public static final DataFlavor POSTSCRIPT_FLAVOR = new DataFlavor("application/postscript", "Postscript");
private static DataFlavor[] supportedFlavors = {
DataFlavor.imageFlavor,
POSTSCRIPT_FLAVOR,
DataFlavor.stringFlavor
private static JPanel chart;
private int width;
private int height;
public Freep(JPanel theGraph, int width, int height) {
this.theGraph = Graphs;
this.width = width;
this.height = height;
//******This is the key method right here: It is ALWAYS imageFlavor, never anything else. How do I make this an EPS flavor?
public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(DataFlavor.imageFlavor)) {
return GraphMaker.image;
else if (flavor.equals(POSTSCRIPT_FLAVOR)) {
return new ByteArrayInputStream(epsOutputStream().toByteArray());
else if (flavor.equals(DataFlavor.stringFlavor)) {
return epsOutputStream().toString();
} else{
throw new UnsupportedFlavorException(flavor);
private ByteArrayOutputStream epsOutputStream() throws IOException {
EPSDocumentGraphics2D g2d = new EPSDocumentGraphics2D(false);
g2d.setGraphicContext(new org.apache.xmlgraphics.java2d.GraphicContext());
ByteArrayOutputStream out = new ByteArrayOutputStream();
public DataFlavor[] getTransferDataFlavors() {
return supportedFlavors;
public boolean isDataFlavorSupported(DataFlavor flavor) {
for(DataFlavor f : supportedFlavors) {
if (f.equals(flavor))
return true;
return false;
public void lostOwnership(Clipboard arg, Transferable arg1) {
The same happens with FreeHEP - I want the flavor to be EMF, but the program sees an image so it is always imageFlavor. I know I am missing something, but what, I don't know.
thanks for your help.I don't think there's a built-in solution. One workaround I've seen is to create a dummy graphics class that overrides the desired drawing functions. Instead of actually drawing pixels, the object writes postscript commands to a buffer. There also seems to be commercial code that does exactly this.
-
I want to have DisplayObject that will randomly contain bitmaps/vectors from some database. I want to implement this using only code. How?
use the loader class:
var loader:Loader=new Loader();
loader.load(new URLRequest("image1.jpg"));
addChild(loader); // or, yourdisplayobject.addChild(loader) -
How do I edit individual vector graphics on a background layer?
I am using Photoshop CS6. I have a .psd file with a background layer that has a sublayer called "bitmap".
I want to resize the rectangles on the background layer, and add additional "button" graphics, but am unable to edit any one shape.I was a bit confused as there were vector masks and layer masks that I was able to reveal from the Layer menu.
-
How to Use the Scalable Vector Graphics API (JSR 226)
im doin an Application with Maps and locations...
i need 2 use the Scalable Vector Graphics API (JSR 226)..
can anyone plz guide me to get it and use the API.. Im using netBeans 5.0
it will be great help :)
Regards
Muhammedh aka MNMThanks Rohan :)
i did read some stuff from the URLs u gav me :)
and I manage 2 solve the prob i had :) (Thank God)
1. downloaded latest version of netBeans (5.5)
2. Java SDK 6 :D...
3. the key thing: Wireless tool kit for CLDC 2.5 Beta
now when u create a project make sure u set the above given tool kit :)
when u set it.. u get an option 2 select the APIs frm a List.. Check on SVG API :)...
Other APIs Such as,
* wireless Messaging API
* Location API
and many more...
Cheers 2 Every1 :)
regards
Muhammedh -
How to crop or mask vector graphic compositions?
Hi Team,
I'm loving Fireworks CS5, and want to take advantage the CSS & Images export features. This, of course, requires that design elements fit into the rectangles to be used as the "div containers" and do not overlap them. Often the original design of the element exceeds the dimensions of the container. Is there a way to crop the composition?
Here's an example:
I want to add a bit of shadow at the ends of the rectangles below.
Step 1: I've created shadowy elipses to partially overlay the ends of the rectangle.
Step 2: I overlay the ends of the rectangle
Step 3: Now I'm stuck. Can't find a way to mask, punch, or crop the resulting composition to produce a result similar to the "flattened bitmap" below.
Can this be done? It would be great if I could continue to edit the source components as vectors and didn't have to flatten to bitmap.
Many thanks,
MonuSorry Linda,
Your advice made perfect sense, and paste-inside looks good on screen. However, when exporting to CSS, I'm getting the error "header_bg_elipse_right overlaps with header_bg".It seems that having the handles poking out beyond the dimensions of the mask upsets the export
Any other ideas?
Thanks
Monu -
How to resize my desktop dimension fla files to mobile dimension fla files
I have 100 desktop dimension fla files . with this now I want to do android application . so can you please anyone tell me how to resize in simple way . such that every file should resize to same dimension.
softwate development tool : flash pro CC
extension : air for android 16
mobile dimension : 5 inchassign the stage scaleMode to exactFit
-
HELP: S10, how to resize or create new partion
anybody can help me plz...
how to resize or create new partion
thanks...Hi and welcome to the lenovo forum,
the quickstart itself will/ is install/ed in hidden folders on the windows partition. Installed as a normal program and de-/re-installable , its available in the download driver section .
Next ..that used free software has no spy/nag or virus in ..
Important is Do as a first step , backup/save the whole hdd on an extra media external hdd i.e.because changing position and size you could loose your recovery function...!
Resize and Partition/correction will easy managed by partioning tool in windows after apply it restarts and do the action for you...
Aware you can loose with grub and linux install your recovery feature ... quickstart is totally independed about that..so if that proggy is activated in BIOS/or windows ...and you have installed i.e. linux, see whats happen when you start ... start ...quickstart will comes first , you can use quickstart or ... if you didnt press any key while starting (boot-progress) it will go further, grubloader comes up now you can choose boot to windows or linux ...
a triple multi system ...
sincerely KalvinKlein
Thinkies 2x X200s/X301 8GB 256GB SSD @ Win 7 64
Ideas Centre A520 ,Yoga 2 256GB SSD,Yoga 2 tablet @ Win 8.1 -
How to resize a photo from CameraUI?
Hi there,
i really need som help here. I cant seem understand how to resize an still image taken with the camera. Here are the code so far(also with the upload part). I just need a thumbnail to be uploaded to the server, not the HQ-image. Any ideas?
Simple AIR for iOS Package for selecting a cameraroll photo or taking a photo and processing it.
Copyright 2012 FIZIX Digital Agency
http://www.fizixstudios.com
For more information see the tutorial at:
http://www.fizixstudios.com/labs/do/view/id/air-ios-camera-and-uploading-photos
Notes:
This is a barebones script and is as generic as possible. The upload process is very basic,
the tutorial linked above gives information on how to post the image along with data to
your PHP script.
The PHP script will collect as $_FILES['Filedata'];
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.TouchEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;
import flash.media.Camera;
import flash.media.CameraUI;
import flash.media.CameraRoll;
import flash.media.MediaPromise;
import flash.media.MediaType;
import flash.events.MediaEvent;
import flash.events.Event;
import flash.events.ErrorEvent;
import flash.utils.IDataInput;
import flash.events.IEventDispatcher;
import flash.events.IOErrorEvent;
import flash.utils.ByteArray;
import flash.filesystem.File;
import flash.filesystem.FileMode;
import flash.filesystem.FileStream;
import flash.errors.EOFError;
import flash.net.URLRequest;
import flash.net.URLVariables;
import flash.net.URLRequestMethod;
// Define properties
var cameraRoll:CameraRoll = new CameraRoll(); // For Camera Roll
var cameraUI:CameraUI = new CameraUI(); // For Taking a Photo
var dataSource:IDataInput; // Data Source
var tempDir; // Our temporary directory
CameraTest() ;
function CameraTest()
Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
// Start the home screen
startHomeScreen();
// =================================================================================
// startHomeScreen
// =================================================================================
function startHomeScreen()
trace("Main Screen Initialized");
// Add main screen event listeners
if(Multitouch.supportsGestureEvents)
mainScreen.startCamera.addEventListener(TouchEvent.TOUCH_TAP, initCamera);
mainScreen.startCameraRoll.addEventListener(TouchEvent.TOUCH_TAP, initCameraRoll);
else
mainScreen.startCamera.addEventListener(MouseEvent.CLICK, initCamera);
mainScreen.startCameraRoll.addEventListener(MouseEvent.CLICK, initCameraRoll);
// =================================================================================
// initCamera
// =================================================================================
function initCamera(evt:Event):void
trace("Starting Camera");
if( CameraUI.isSupported )
cameraUI.addEventListener(MediaEvent.COMPLETE, imageSelected);
cameraUI.addEventListener(Event.CANCEL, browseCancelled);
cameraUI.addEventListener(ErrorEvent.ERROR, mediaError);
cameraUI.launch(MediaType.IMAGE);
else
mainScreen.feedbackText.text = "This device does not support Camera functions.";
// =================================================================================
// initCameraRoll
// =================================================================================
function initCameraRoll(evt:Event):void
trace("Opening Camera Roll");
if(CameraRoll.supportsBrowseForImage)
mainScreen.feedbackText.text = "Opening Camera Roll.";
// Add event listeners for camera roll events
cameraRoll.addEventListener(MediaEvent.SELECT, imageSelected);
cameraRoll.addEventListener(Event.CANCEL, browseCancelled);
cameraRoll.addEventListener(ErrorEvent.ERROR, mediaError);
// Open up the camera roll
cameraRoll.browseForImage();
else
mainScreen.feedbackText.text = "This device does not support CameraRoll functions.";
// =================================================================================
// imageSelected
// =================================================================================
function imageSelected(evt:MediaEvent):void
mainScreen.feedbackText.text = "Image Selected";
// Create a new imagePromise
var imagePromise:MediaPromise = evt.data;
// Open our data source
dataSource = imagePromise.open();
if(imagePromise.isAsync )
mainScreen.feedbackText.text += "Asynchronous Mode Media Promise.";
var eventSource:IEventDispatcher = dataSource as IEventDispatcher;
eventSource.addEventListener( Event.COMPLETE, onMediaLoaded );
else
mainScreen.feedbackText.text += "Synchronous Mode Media Promise.";
readMediaData();
// =================================================================================
// browseCancelled
// =================================================================================
function browseCancelled(event:Event):void
mainScreen.feedbackText.text = "Browse CameraRoll Cancelled";
// =================================================================================
// mediaError
// =================================================================================
function mediaError(event:Event):void
mainScreen.feedbackText.text = "There was an error";
// =================================================================================
// onMediaLoaded
// =================================================================================
function onMediaLoaded( event:Event ):void
mainScreen.feedbackText.text += "Image Loaded.";
readMediaData();
// =================================================================================
// readMediaData
// =================================================================================
function readMediaData():void
mainScreen.feedbackText.text += "Reading Image Data.";
var imageBytes:ByteArray = new ByteArray();
dataSource.readBytes( imageBytes );
tempDir = File.createTempDirectory();
// Set the userURL
var serverURL:String = "http://www.hidden_in_this_example.com/upload.php";
// Get the date and create an image name
var now:Date = new Date();
var filename:String = "IMG" + now.fullYear + now.month + now.day + now.hours + now.minutes + now.seconds;
// Create the temp file
var temp:File = tempDir.resolvePath(filename);
// Create a new FileStream
var stream:FileStream = new FileStream();
stream.open(temp, FileMode.WRITE);
stream.writeBytes(imageBytes);
stream.close();
// Add event listeners for progress
temp.addEventListener(Event.COMPLETE, uploadComplete);
temp.addEventListener(IOErrorEvent.IO_ERROR, ioError);
// Try to upload the file
try
mainScreen.feedbackText.text += "Uploading File";
//temp.upload(new URLRequest(serverURL), "Filedata");
// We need to use URLVariables
var params:URLVariables = new URLVariables();
// Set the parameters that we will be posting alongside the image
params.userid = "1234567";
// Create a new URLRequest
var request:URLRequest = new URLRequest(serverURL);
// Set the request method to POST (as opposed to GET)
request.method = URLRequestMethod.POST;
// Put our parameters into request.data
request.data = params;
// Perform the upload
temp.upload(request, "Filedata");
catch( e:Error )
trace(e);
mainScreen.feedbackText.text += "Error Uploading File: " + e;
removeTempDir();
// =================================================================================
// removeTempDir
// =================================================================================
function removeTempDir():void
tempDir.deleteDirectory(true);
tempDir = null;
// ==================================================================================
// uploadComplete()
// ==================================================================================
function uploadComplete(event:Event):void
mainScreen.feedbackText.text += "Upload Complete";
// ==================================================================================
// ioError()
// ==================================================================================
function ioError(event:Event):void
mainScreen.feedbackText.text += "Unable to process photo";1. Create a BitmapData of the correct size of the full image
2. Use BitmapData.setPixels to create pixel data from your byteArray
3. Make a new Bitmap, Bitmap.bitmapData = BitmapData
4. Create a matrix with the correct scaling factors for your thumbnail
5. Create a new BitmapData the size of your thumb
6. Use BitmapData.draw to draw your image data from the Bitmap to the new BitmapData with the scaling matrix
7. Use BitmapData.getPixels to create a bytearray from your thumb BitmapData
8. save it
You'll have to look up the AS3 reference to see how all these methods work. -
How to resize a jpg/gif file to a fix size using jimi ?
I have search from the web and didn't find any example on doing this.
Can any one give example on how to resize a jpg image. let say 120x240
to a fixed size 40x40 ?
thank youHi.
When you got that image in form of a file, just load it and invoke the image's getScaledInstance(...)-method.
Here's how it could work:
import java.awt.*;
public class Test {
public static void main(String[] argv) {
// define where the image comes from:
URL toImage = new URL("file:/C:/test.jpg"); // or the like
// get the image:
Image image = Toolkit.getDefaultToolkit().createImage(toImage);
// scale the image to target size (40x40 here):
Image smallImage = image.getScaledInstance(40, 40, Image.SCALE_DEFAULT);
// you might want to do other things like displaying it afterwards
}HTH & cheers,
kelysar -
How to create a simple idoc in practice? can you provide an example?
how to create a simple idoc in practice? can you provide an example with full source code?
Try with the follwoing steps
Sending System(Outbound ALE Process)
Tcode SALE ³ for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ¡V Create Model View
Tcode BD82 ¡V Generate partner Profiles & Create Ports
Tcode BD64 ¡V Distribute the Model view
This is Receiving system Settings
Receiving System(Inbound ALE )
Tcode SALE ³ for
a) Define Logical System
b) Assign Client to Logical System
Tcode SM59-RFC Destination
Tcode BD64 ¡V Check for Model view whether it has distributed or not
Tcode BD82 -- Generate partner Profiles & Create Ports
Tcode BD11 Getting Material Data
Tcode WE05 ¡V Idoc List for inbound status codes
Message Type MATMAS
Tcode BD10 ¡V Send Material Data
Tcode WE05 ¡V Idoc List for watching any Errors
1)a Goto Tcode SALE
Click on Sending & Receiving Systems-->Select Logical Systems
Here Define Logical Systems---> Click on Execute Button
go for new entries
1) System Name : ERP000
Description : Sending System
2) System Name : ERP800
Description : Receiving System
press Enter & Save
it will ask Request
if you want new request create new Request orpress continue for transfering the objects
B) goto Tcode SALE
Select Assign Client to Logical Systems-->Execute
000--> Double click on this
Give the following Information
Client : ERP 000
City :
Logical System
Currency
Client role
Save this Data
Step 2) For RFC Creation
Goto Tcode SM59-->Select R/3 Connects
Click on Create Button
RFC Destination Name should be same as partner's logical system name and case sensitive to create the ports automatically while generating the partner profiles
give the information for required fields
RFC Destination : ERP800
Connection type: 3
Description
Target Host : ERP000
System No:000
lan : EN
Client : 800
User : Login User Name
Password:
save this & Test it & RemortLogin
3)
Goto Tcode BD64 -- click on Change mode button
click on create moduleview
short text : xxxxxxxxxxxxxx
Technical Neme : MODEL_ALV
save this & Press ok
select your just created modelview Name :'MODEL_ALV'.
goto add message type
Model Name : MODEL_ALV
sender : ERP000
Receiver : ERP800
Message type :MATMAS
save & Press Enter
4) Goto Tcode BD82
Give Model View : MODEL_ALV
Partner system : ERP800
execute this by press F8 Button
it will gives you sending system port No :A000000015(Like)
5) Goto Tcode BD64
seelct the modelview
goto >edit>modelview-->distribute
press ok & Press enter
6)goto Tcode : BD10 for Material sending
Material : mat_001
Message Type : MATMAS
Logical System : ERP800
and Execute
7)goto Tcode : BD11 for Material Receiving
Material : mat_001
Message Type : MATMAS
and Execute --> 1 request idoc created for message type Matmas
press enter
Thanks & regards
Sreenivas
Here Master Idoc set for Messge type MATMAS-->press Enter
1 Communication Idoc generated for Message Type
this is your IDOC
Take a look at this guide.
http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
http://www.allsaplinks.com/idoc_sample.html
http://www.sappoint.com/abap/ale.pdf
http://www.sappoint.com/abap/ale2.pdf
http://www.sapgenie.com/ale/configuration.htm
http://www.sappoint.com/abap/ale.pdf
http://www.sappoint.com/abap/ale2.pdf
http://www.sapdevelopment.co.uk/training
http://www.sappro.com/downloads/OneClientDistribution.pdf
http://www.sapgenie.com/sapgenie/docs/ale_scenario_development_procedure.doc
Create The Extension Segment
Transaction: WE31
The first step in extending an IDoc is to create the new segments that will go into that IDoc. There are some rules that you need to follow when creating the segments:
- The name of each segment type must start with Z1
- For each field in the segment you need to define a field name and a
data element.
- The data element for the segment structure must be of data type CHAR.
How to create new segments:
Run the segment maintenance transaction WE31.
Type your new segment name, and click on Create.
Define the fields of your segment:
Field name
Data Element for the field (from the ABAP dictionary).
Do not change the Export length!
Save the segment
Run Segment -->Check to check the segment for consistency.
Release the segment for transport. Select Edit -->Set Release. Note that the Release column now has a check mark.
Create the Extension IDoc Type
Transaction: WE30
After you create the segments to be added to the extension type, you can create the extension type itself. Execute transaction WE30, enter the extension name, select Extension type, and click Create. You now have three options:
Create new type: Does not refer to other extension types
Create copy: Copies info from an extension type that already exists
Create successor: Extends an extension type from a previous release
of R/3. You can only have one version of an extension type for
each release.
Enter the Basic IDoc type that this extension type will extend.
The screen now shows the structure of the IDoc type you used as
a reference.
Position the cursor on one of the segments and click Create. This will insert an extension segment as a child of the selected segment.
NOTE: A segment cannot appear more than once in an IDoc type! You must control the use of duplicate segments with the segment attributes (the next screen).
The segment attribute screen appears. Enter the information and save.
Extension segments should not be mandatory (for future upgrades), and will need to have minimum and maximum number of instances defined. This answers the question, for each instance of the parent segment, how many instances of the child segment may we have?
You can press the Segment Editor pushbutton to view or change the segment definition.
Create the new Message Type
You can only use an extension IDoc type by assigning it to a message type. You can create a new message type for this.
First the message type itself needs to be created.
Transaction: WE81
Create a new entry and save. Use SAP established customer naming conventions (good form is to start with a Z and retain the rest of the related SAP message type, so, for example, MATMAS becomes ZMATMAS).
After creating the message type, associate it with the corresponding Basic IDoc Type and Extension Type. This relationship is used when IDocs are sent to or received from a partner to determine what segments are valid and what the hierarchy for those segments is.
Transaction: WE82
Create a new entry and enter the Message type, Basic IDoc type, Extension type, and Release, and save your data. Note: the release assignment is not valid for prior SAP releases.
One message type can be associated with many basic IDoc types; however, you need a one-to-one relationship for distribution via ALE.
regards,
srinivas
*reward for useful answers*</b> -
How to resize JPanel at Runtime ??
Hi,
Our Project me t a problem as below, we hope to resize JPanel at Runtime , not at design time, ie, when we first click the button called "Move JPanel" , then we click the JPanel, then we can drag it around within main panel, but we hope to resize the size of this JPanel when we point to the border of this JPanel then drag its border to zoom in or zoom out this JPanel.
Please advice how to do that??
Thanks in advance.
import java.awt.*;
import java.awt.event.*;
import java.awt.geom.*;
import java.util.Vector;
import javax.swing.*;
import javax.swing.border.LineBorder;
import javax.swing.event.*;
public class ResizeJPanels extends JPanel
protected JLabel label1, label2, label3, label4, labeltmp;
protected JLabel[] labels;
protected JPanel[] panels;
protected JPanel selectedJPanel;
protected JButton btn = new JButton("Move JPanel");
int cx, cy;
protected Vector order = new Vector();
public static void main(String[] args)
JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new ResizeJPanels().GroupJLabels());
f.setSize(600,700);
f.setLocation(200,200);
f.setVisible(true);
private MouseListener ml = new MouseAdapter() {
public void mousePressed(MouseEvent e) {
Point p = e.getPoint();
JPanel jp = new JPanel();
jp.setLayout(null);
Component[] c = ((JPanel)e.getSource()).getComponents();
System.out.println("c.length = " + c.length);
for(int j = 0; j < c.length; j++) {
if(c[j].getBounds().contains(p)) {
if(selectedJPanel != null && selectedJPanel != (JPanel)c[j])
selectedJPanel.setBorder(BorderFactory.createEtchedBorder());
selectedJPanel = (JPanel)c[j];
selectedJPanel.setBorder(BorderFactory.createLineBorder(Color.green));
break;
add(jp);
revalidate();
public JPanel GroupJLabels ()
setLayout(null);
addLabels();
label1.setBounds( 125, 150, 125, 25);
label2.setBounds(425, 150, 125, 25);
label3.setBounds( 125, 575, 125, 25);
label4.setBounds(425, 575, 125, 25);
//add(btn);
btn.setBounds(10, 5, 205, 25);
add(btn);
determineCenterOfComponents();
ComponentMover mover = new ComponentMover();
ActionListener lst = new ActionListener() {
public void actionPerformed(ActionEvent e) {
ComponentMover mover = new ComponentMover();
addMouseListener(mover);
addMouseMotionListener(mover);
btn.addActionListener(lst);
addMouseListener(ml);
return this;
public void paintComponent(final Graphics g)
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);
Point[] p;
g2.setStroke(new BasicStroke(4f));
for(int i = 0 ; i < order.size()-1; i++) {
JPanel l1 = (JPanel)order.elementAt(i);
JPanel l2 = (JPanel)order.elementAt(i+1);
p = getCenterPoints(l1, l2);
g2.setColor(Color.black);
// g2.draw(new Line2D.Double(p[0], p[1]));
private Point[] getCenterPoints(Component c1, Component c2)
Point
p1 = new Point(),
p2 = new Point();
Rectangle
r1 = c1.getBounds(),
r2 = c2.getBounds();
p1.x = r1.x + r1.width/2;
p1.y = r1.y + r1.height/2;
p2.x = r2.x + r2.width/2;
p2.y = r2.y + r2.height/2;
return new Point[] {p1, p2};
private void determineCenterOfComponents()
int
xMin = Integer.MAX_VALUE,
yMin = Integer.MAX_VALUE,
xMax = 0,
yMax = 0;
for(int i = 0; i < labels.length; i++)
Rectangle r = labels.getBounds();
if(r.x < xMin)
xMin = r.x;
if(r.y < yMin)
yMin = r.y;
if(r.x + r.width > xMax)
xMax = r.x + r.width;
if(r.y + r.height > yMax)
yMax = r.y + r.height;
cx = xMin + (xMax - xMin)/2;
cy = yMin + (yMax - yMin)/2;
private class ComponentMover extends MouseInputAdapter
Point offsetP = new Point();
boolean dragging;
public void mousePressed(MouseEvent e)
Point p = e.getPoint();
for(int i = 0; i < panels.length; i++)
Rectangle r = panels[i].getBounds();
if(r.contains(p))
selectedJPanel = panels[i];
order.addElement(panels[i]);
offsetP.x = p.x - r.x;
offsetP.y = p.y - r.y;
dragging = true;
repaint(); //added
break;
public void mouseReleased(MouseEvent e)
dragging = false;
public void mouseDragged(MouseEvent e)
if(dragging)
Rectangle r = selectedJPanel.getBounds();
r.x = e.getX() - offsetP.x;
r.y = e.getY() - offsetP.y;
selectedJPanel.setBounds(r.x, r.y, r.width, r.height);
//determineCenterOfComponents();
repaint();
private void addLabels()
label1 = new JLabel("Label 1");
label2 = new JLabel("Label 2");
label3 = new JLabel("Label 3");
label4 = new JLabel("Label 4");
labels = new JLabel[] {
label1, label2, label3, label4
JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
jl.setBackground(Color.green);
jl.setOpaque(true);
jl.setFont(new Font("Helvetica", Font.BOLD, 18));
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
panels = new JPanel[]{jp};
jp.setBorder(new LineBorder(Color.black, 3, false));
jp.setPreferredSize(new Dimension(400,200));
jp.add(jl, BorderLayout.NORTH);
for(int i = 0; i < labels.length; i++)
labels[i].setHorizontalAlignment(SwingConstants.CENTER);
labels[i].setBorder(BorderFactory.createEtchedBorder());
jp.add(labels[i], BorderLayout.CENTER);
jp.setBounds(100, 100, 400,200);
add(jp);import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.MouseInputAdapter;
public class Resizing extends JPanel {
public Resizing() {
super(null);
addPanel();
PanelControlAdapter control = new PanelControlAdapter(this);
addMouseListener(control);
addMouseMotionListener(control);
private void addPanel() {
JLabel jl = new JLabel("This is resizeable JPanel at Runtime");
jl.setBackground(Color.green);
jl.setOpaque(true);
jl.setFont(new Font("Helvetica", Font.BOLD, 18));
JPanel jp = new JPanel();
jp.setLayout(new BorderLayout());
jp.setBorder(new LineBorder(Color.black, 3, false));
jp.add(jl, BorderLayout.NORTH);
jp.setBounds(50,50,400,200);
add(jp);
public static void main(String[] args) {
JFrame f = new JFrame("Test");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.getContentPane().add(new Resizing());
f.setSize(500,400);
f.setLocation(100,100);
f.setVisible(true);
class PanelControlAdapter extends MouseInputAdapter {
Resizing host;
Component selectedComponent;
LineBorder black;
LineBorder green;
Point offset = new Point();
Point start = new Point();
boolean dragging = false;
boolean resizing = false;
public PanelControlAdapter(Resizing r) {
host = r;
black = new LineBorder(Color.black, 3, false);
green = new LineBorder(Color.green, 3, false);
public void mouseMoved(MouseEvent e) {
Point p = e.getPoint();
boolean hovering = false;
Component c = host.getComponent(0);
Rectangle r = c.getBounds();
if(r.contains(p)) {
hovering = true;
if(selectedComponent != c) {
if(selectedComponent != null) // reset
((JComponent)selectedComponent).setBorder(black);
selectedComponent = c;
((JComponent)selectedComponent).setBorder(green);
if(overBorder(p))
setCursor(p);
else if(selectedComponent.getCursor() != Cursor.getDefaultCursor())
selectedComponent.setCursor(Cursor.getDefaultCursor());
if(!hovering && selectedComponent != null) {
((JComponent)selectedComponent).setBorder(black);
selectedComponent = null;
private boolean overBorder(Point p) {
Rectangle r = selectedComponent.getBounds();
JComponent target = (JComponent)selectedComponent;
Insets insets = target.getBorder().getBorderInsets(target);
// Assume uniform border insets.
r.grow(-insets.left, -insets.top);
return !r.contains(p);
private void setCursor(Point p) {
JComponent target = (JComponent)selectedComponent;
AbstractBorder border = (AbstractBorder)target.getBorder();
Rectangle r = target.getBounds();
Rectangle ir = border.getInteriorRectangle(target, r.x, r.y, r.width, r.height);
int outcode = ir.outcode(p.x, p.y);
Cursor cursor;
switch(outcode) {
case Rectangle.OUT_TOP:
cursor = Cursor.getPredefinedCursor(Cursor.N_RESIZE_CURSOR);
break;
case Rectangle.OUT_TOP + Rectangle.OUT_LEFT:
cursor = Cursor.getPredefinedCursor(Cursor.NW_RESIZE_CURSOR);
break;
case Rectangle.OUT_LEFT:
cursor = Cursor.getPredefinedCursor(Cursor.W_RESIZE_CURSOR);
break;
case Rectangle.OUT_LEFT + Rectangle.OUT_BOTTOM:
cursor = Cursor.getPredefinedCursor(Cursor.SW_RESIZE_CURSOR);
break;
case Rectangle.OUT_BOTTOM:
cursor = Cursor.getPredefinedCursor(Cursor.S_RESIZE_CURSOR);
break;
case Rectangle.OUT_BOTTOM + Rectangle.OUT_RIGHT:
cursor = Cursor.getPredefinedCursor(Cursor.SE_RESIZE_CURSOR);
break;
case Rectangle.OUT_RIGHT:
cursor = Cursor.getPredefinedCursor(Cursor.E_RESIZE_CURSOR);
break;
case Rectangle.OUT_RIGHT + Rectangle.OUT_TOP:
cursor = Cursor.getPredefinedCursor(Cursor.NE_RESIZE_CURSOR);
break;
default:
cursor = Cursor.getDefaultCursor();
selectedComponent.setCursor(cursor);
public void mousePressed(MouseEvent e) {
Point p = e.getPoint();
if(selectedComponent != null) {
Rectangle r = selectedComponent.getBounds();
if(selectedComponent.getCursor() == Cursor.getDefaultCursor()) {
offset.x = p.x - r.x;
offset.y = p.y - r.y;
dragging = true;
} else {
start = p;
resizing = true;
public void mouseReleased(MouseEvent e) {
dragging = false;
resizing = false;
public void mouseDragged(MouseEvent e) {
Point p = e.getPoint();
if(dragging || resizing) {
Rectangle r = selectedComponent.getBounds();
if(dragging) {
r.x = p.x - offset.x;
r.y = p.y - offset.y;
selectedComponent.setLocation(r.x, r.y);
} else if(resizing) {
int type = selectedComponent.getCursor().getType();
switch(type) {
case Cursor.N_RESIZE_CURSOR:
r.height -= p.y - start.y;
r.y = p.y;
break;
case Cursor.NW_RESIZE_CURSOR:
r.width -= p.x - start.x;
r.x = p.x;
r.height -= p.y - start.y;
r.y = p.y;
break;
case Cursor.W_RESIZE_CURSOR:
r.width -= p.x - start.x;
r.x = p.x;
break;
case Cursor.SW_RESIZE_CURSOR:
r.width -= p.x - start.x;
r.x = p.x;
r.height += p.y - start.y;
break;
case Cursor.S_RESIZE_CURSOR:
r.height += p.y - start.y;
break;
case Cursor.SE_RESIZE_CURSOR:
r.width += p.x - start.x;
r.height += p.y - start.y;
break;
case Cursor.E_RESIZE_CURSOR:
r.width += p.x - start.x;
break;
case Cursor.NE_RESIZE_CURSOR:
r.width += p.x - start.x;
r.height -= p.y - start.y;
r.y = p.y;
break;
default:
System.out.println("Unexpected resize type: " + type);
selectedComponent.setBounds(r.x, r.y, r.width, r.height);
start = p;
} -
How to resize my monitor resolution in OS X 10.5.8
Hello I have a question I am new to mac and I was trying to resize my desktop resolution. I'm using a 720i TV utilizing the HDMI and using the convertor to make it DVI and for some reason when I use the 720 resolution its all off center and it won't let me resize it like it does in Windows but it works when i have it at 1280 x 960 problem is I don't want that resolution it doesn't look as good on my TV. I have tried everything and can't find any software that will allow me to do this. And I use the same monitor for my Windows machine and it works perfect PLEASE HELP
Yeah..... I know that I want to know how to resize a resolution the 1280 x 720 doesn't show up right it's making everything go off the sides so I can't see everything on my desktop in windows my nvidia control panel would allow me to resize my monitor to fit any resolution i want to know how to do that on a mac
-
How to resize all pages -Acrobat 9 Pro Extended ? ?
I came across a pre-existing pdf file of an old book of genealogy. According to the front pages, it was 'Digitized by Microsoft', so I know nothing on how it was generated. Total pages are in excess of 1,100.
In viewing the pages, they are reflected as 2 pages to a view; not the book opened with the spine in the middle, but images side by side ... in numerical order ... and they appear as a normal sized 2 page for that view. When I print out a page, by number, it also prints out in a normal size on an 8x11 inch sheet of paper.
However, rather than print page by page on individual sheets of paper, I want to print out multiple pages, 2 to a sheet of paper. In doing this, the images of the pages come up as 3x5 inch; thus not readable if printed without the usage of magnifier.
Not that familiar with the program, but tried to do a resize process by setting some adjustments and then to a new pdf file. It did not change that much ... and increased the file size dramatically.
I am a novice to these processes. Can someone advise how to resize the whole file, with images of pages side by side, so that when multiple print is used for 2 pages the size comes up closer to something like 5x7 inch each?
ThanksLet me try it this way.....
1. The pdf file, when initially opened up, in the opening view shows 2 simotaneous pages side by side ... with hardly a divider between them. This at this point has nothing to do with the print mode.
2. The book in question was 'Digitized by Microsoft' ... don't know if that makes any difference, but thought it would help to under stand that it was not created by the normal Adobe Acrobat method.
3. Now, when I go to the Print mode, from where I just viewed the 2-side-by-side pages, the initial view there, for 'page', is just 1 page ... not the 2 page view I just came from ... and it will print out this view in a full sheet version.
4. But, not wanting to print out 1130 pages, want to print multi-page as allowed under Acrobat options.
5. So choose multi-page and 2 pages and "Print to printable area"..
6. When this option appears in the print viewing window, the 'images' (presuming that to be the correct reference) are small, over the normal (roughly) 5 x 7 inch (each) for a 2-page print option.
7. With the 2-page print option, the images are only 3.5 x 5.25 inches ... rather than something like 5 x 7 inch ... which is difficult to read without a magnifier. [Note: This 3.5 x 5.25 is as indicated in Properties that the original 'Digitizing' did.
8. So, in essence, how can one change the default individual image size from 3.5 x 5.25 inch size, to something closer to 5 x 7 inch size ... so that each image fills in more of it's half of the 8.5 x 11 inch page being printed ... rather than the small size reflected in the attached jpg ?
I've attached a jpg of the print screen, and one of the 2 page side-by-side 'default' view in Acrobat.
Thanks
Maybe you are looking for
-
Run the Report as a Background job and Get the Output in Excel in Local PC
Hello Gurus, I have one following requirement. One should be able to run the report as a background job and it should be possible to get the report in Excel format, also when running the report in background. The excel report should have the same inf
-
Finaly!! AVG Antivirus for Windows 64 bit!
Hi guy's, I just discovered that the best free Virus-scanner for private users does support 64bit Windows now.... This is great news. You can download the free version here: >>AVG Free Edition<< Beware, only the paid version supports 64bit, but hey,
-
Problem in sql pass through query
i am using the following query: select * from table_name where item IN (?0) and item1 IN (?1) i am creating sqlPassthroughQuery but i am getting : Missing right parenthesis /Query not terminated properly exception but the query is working without whe
-
"Service Battery" after recalibration and SMC reset
I purchased a unibody 13'' MacBook Pro 13 months ago (and didn't have the foresight to buy Apple Care, oof) and I've lately been running into some battery issues. I live overseas and I've been traveling a lot recently. I just moved into a new apartme
-
I consolidated my library to an external hard drive, a few days later the drive crashed. Everything still exists on the local computer in the old locations. How do I tell iTunes to use the old locations again? I don't need to redownload anything, I h