Custom shapes: zooming and picking

I need design advice regarding a screen-full of custom shapes I am making: my app will draw literally thousands of primitive octagons. I have seen this issue in other threads, but answers didn't fully apply to my situation.
Using Graphics2D's scale, I will enable zooming ability. The current problem involves zooming: getting contains() to work in the event I'm zoomed in or out. I've heard of a method that AffineTransform has that returns you a transformed shape?
Assuming that works, then I still have to run contains(), followed by AffineTransform's transformed shape method roughly 4000 times. Any advice on this? If performance isn't instantaneous I'm going to have to choose a clever data structure/alg.
The octagons are more or less in "grid format" and it forms a big rectangular array. Thanks!

Yes, you shouldn't need to transform your shapes either for rendering or hit tests.
Note that if you frequently have to perform that many tests and a significant number of your shapes are non-rectangular, you may (depending on how contains() is implemented for each shape) get a performance benefit by caching the bounding boxes of each shape - rectangles are of course the quickest hit-test available and once you've tested those you can perform a proper contains() on the shapes themselves. You could perhaps optimise the test further by storing lists/arrays of bounding boxes sorted by positions of each edge so that you don't need to test all 4000.
How much benefit you get from these strategies depends on both your use case and your data, which obviously I can only guess at.

Similar Messages

  • Tutorial:  Creating, saving and re-using Custom Shapes

    I've beeen experimenting with custom shapes for the last couple of days, and thought I'd share some of the tips and techniques I found.
    First of all, what are custom shapes?
    Well, they're vector objects.  That means that they are not built out of millions of individual pixels (like images are), but rather they're a series of mathematical statements that describe how to draw a line from point to point to create the vector shape.  This means that custom shapes are "resolution independent", and that they can be grossly shrunk or enlarged and still retain razor sharp edges, curves and corners.
    What are custom shapes good for?
    Pretty much anything where you want to use a good, sharp object.  In particular, using a custom shape as a clipping mask for an image that's been placed as a Smart Object is an outstanding technique, and really shows off the power that PSE is capable of.
    PSE comes with a lot of ready-to-use custom shapes for its Custom Shape tool, and there are probably hundreds of thousands available on the Web -- just search for "photoshop shapes".  Typically, those shapes will be supplied as Adobe CSH (Custom SHape) files, and simply copying the CSH files into the
    "C:\Program Files (x86)\Adobe\Photoshop Elements 10\Presets\Custom Shapes"
    directory will make them available for use with the Custom Shape tool.
    Sooner or later, though, you'll get the itch to create your own custom shapes.  Out of the box, PSE does not have the capability to let you create custom shapes and add them to the CSH files like the "big" Photoshop does, so we'll need to use a workaround:  store your custom shapes as layers in a PSD file, and when you want to use them simply copy them into your image. 
    N.B.:  To create custom shapes you'll have to use the reasonably priced Elements+ add-in:
    http://elementsplus.net/
    So, the procedure goes like this:
    Create a new image, using the PSE defaults, and save it as "CustomShapes01.psd", keeping it open.
    Open an image containing an object that you want to use as a custom shape.
    Use any of the selection tools to make an accurate selection of the object:
    In the Effects panel, use the Elements+...Paths effect and choose the Create New Path...From Current Selection:
    Use the Elements+...Paths again, choosing "Convert to Shape", giving it a name and colour of your choosing.  This will create a Shape Layer using that name.
    Important:  If your shape has "holes",
    use the Shape Selection tool and click on the shape to select it.  Then hit the "Combine" button in the Options Bar.  This will combine all the individual shapes used to create the shape and its "holes" into one shape, and prevent beaucoup problems later.
    Switch to the Move tool and drag the shape onto the tab of your "CustomShapes01.psd" image, keeping your mouse button pressed.  That image will become activated and you can move your cursor onto the image itself and drop your shape onto it.  Your PSD file will now have your custom shape as a shape layer:
    Save that "CustomShapes01.psd" file.
    You can repeat the process for as many custom shapes as you want, and they will each become a layer in the "CustomShapes01.psd" file.
    To use your custom shape, open the "CustomShapes01.psd" file and your target image and do the drag and drop with the Move tool to copy the custom shape onto your target image.
    I mentioned that using a custom shape as a clipping mask for an image placed as a Smart Object is a very powerful technique.  It's powerful because the custom shape can be altered at any time and still keep its sharpness, and because the Smart Object can also be resized without becoming pixellated.  Of course, that custom shape layer can have any number of layer styles applied to it and those layer styles will "follow" the shape if the shape is moved, resized or rotated.
    Here are three examples of using the custom shapes as clipping masks for Smart Objects:
    In this example, each custom shape is used as a clipping mask for an image Smart Object, as usual:
    Here, one custom shape was used as a clipping mask for an image Smart Object and they were linked. 
    Then the shape and image were duplicated and moved, rotated and resized.  Because of the linking, the Smart Object automatically kept its orientation and size relative to the custom shape throughout:
    If you want to use custom shapes as a "combined" clipping mask, the procedure is a little more complicated because you need to get all your custom shapes on one shape layer. 
    So, after copying your shapes into the target image (as separate shape layers), use the Shape Selection tool to select one of the shapes.  Using Edit...Cut will cut that shape layer to the Clipboard, and you can select one of the other shape layers and use Edit...Paste to paste the custom shape into that shape layer.  Repeat as necessary, and you will get all of your custom shapes on one shape layer.  Then use that single shape layer as your clipping mask:
    The neat thing is that the individual shapes can be selected with the Shape Selection tool and independently moved, resized or rotated as necessary.
    Enjoy!
    Ken

    Thanks, Michel.
    I forgot to mention one point about copying shape layers into one shape layer:  when you initially use the Shape Selection tool to select a shape for cutting, make sure the option for the Shape Selection tool is set to "Add to Selection".
    MichelBParis wrote:
    The problem with Elements+ is that it has so many features you soon forget what it can give you !
    Truer words were never spoken! 
    Ken

  • Installing custom shapes in PSE 7

    I have some .csh files I used when I had PSE 4 and have just upgraded. I've been able to successfully edit the meta data files and install layer styles but can't figure out how to access the custom shapes files. I had expected to click on the double arrow from the custom shape dropdown to get to a "Load shapes" menu but I don't see one. I have Windows XP.

    Well, I figured it out by trial and error I guess. Here is the path where you put the custom shapes (Windows and PSE 7.0).
    C:\Documents and Settings\Lisa\Application Data\Adobe\Photoshop Elements\7.0\Presets\Custom Shapes
    The difference is that we put the layer styles in the path C:\Documents and Settings\All Users\Application Data\Adobe\Photoshop Elements\7.0\Photo Creations\shapes.
    Note the difference between "Lisa" and "All Users".
    After doing this and deleting the ThumbDatabase.db3 and MediaDatabase.db3 files, PSE rebuilt them and my custom shapes now showed up. WHEW!!!! What a pain. I guess the confusing part was the difference in that some things are for A user and not All Users.

  • Foreign trade and customs data should be picked automatically in delivery

    Dear All,
    Foreign trade and customs data should be picked automatically in delivery note and in the invoice  once we enter it in the master data for L/C Local Sales for example country  Saudi arabia to Saudi Arabia in vi95 or any other transaction you have for this particular master data entry.please help

    Check the customizing settings under
    IMG - SD - Foreign Trade/Customs - Basic Data for Foreign Trade -  Define Business Transaction Types And Default Value
    And the data should be picked up from Material Master record in Foreign trade export view.
    They are checked as mandatory fields according to customizing under:
    IMG - SD - Foreign Trade/Customs - Control Foreign Trade Data in MM and SD Documents - Incompleteness Schemas for Foreign Trade Data
    Also, refer following link:
    [Customizing Foreign Trade Master Data |http://wiki.sdn.sap.com/wiki/pages/viewpage.action?spaceKey=ERPLO&title=CustomizingForeignTradeMasterData&decorator=printable]
    Thanks & Regards
    JP

  • WHAT DOES AWAITING CUSTOMER ACTION MEAN AND ACTUAL PICK UP DATE??????​????????

    iTS ALMOST A WEEK SINCE MY ITS BEEN SAYING AWAITING CUSTOMER ACTION? AND ITS BEEN 2 WEEKS SINCE I SHIPPED MY LAPTOP. AT FIRST MY DEILVERY ESTIMATE WAS ON THE 11-15-13 AND NOW IT DOESN'T SHOW ANYMORE. THEN ON THE BUTTOM THEY SAID ACTUAL PICK UP DATE IS ON 11-15-13. SOMEONE HELP PLEASE THIS MAKES NO SENSE!!!!!!!!!!!!!! IF IT DID GET DEILVERD I DIDN'T GET IT! SOMEONE PLEASE HELP OR PLEASE EMAIL ME AT [Personal Information Removed]
    This question was solved.
    View Solution.

    Thank you for visiting the HP Support Forums. I'm sorry but this is a peer-to-peer community of HP customers, and not a venue to contact HP directly. Most of the users here are consumers like yourself who are offering solutions because they like to help others, and any HP employees you see are here on their own capacity and not representing the company.
    If you have additional or direct feedback for HP about their products or services, or questions about repair, you can use the link below for contact information.
    http://www8.hp.com/us/en/contact-hp/ww-contact-us.​html
    If you have other questions and concerns about using the forum, please feel free to send me a private message.
    OrnahP
    HP Support Forums Moderator
     Clicking the "Kudos Star" to the left is a great way to say thanks!
     When your problem has been solved, accept the solution by clicking "Accept as Solution" to help other members in the future!
    Rules of Participation

  • How Do I Create a Vector Image from A Custom Shape?

    I have tried a bunch of tutorials, but I just can't seem to get it to work. I'm using Photoshop CS6. I'll walk you through my process as best I can so that hopefully you can catch the step I'm missing.
    Open new file (If it matters Width is 1280 px, Height is 1024 px, Resolution is 72 ppi, Color mode RGB Color 8 bit, background content Transparent, Color Profile sRGB IEC61966-2.1 and Pixel Aspect Ratio Square Pixels)
    I select my shape
    Create a duplicate layer
    Draw the shape to desired size
    Click Add Layer Mask (Vector Mask is greyed out in Layer menu)
    At this point the shape box is showing in my duplicate layer, but there is no shape within the box, even if I give it a fill color.

    Hi,
    There are several ways, but try something like the following:
    1. Pick a Custom Shape
    2. Set the tool options to Shape
    3. Select the Fill color
    Draw out your shape and you should see a layer in the Layers panel named Shape 1

  • Iterating through bseg line items and picking the vendor line item

    Hello,
    I am creating a report in which i want to show the list of vendors (with their WHT's). The output will be based on selection of a certain period(range). I guess i have to first iterate through BKPF and get those documents that lie in the given range, then i 'll have to iterate through the selected documents in BSEG and pick out the vendor line items (KOART = 'S'). Will i be using GET for this..
    Is this the right way? secondly, if yes, can sumone show me how to iterate through BKPF and BSEG and get vendor details.?
    Thanks..
    SHehryar

    Hey,
    Instead of selecting data from BKPF-BSEG you could use BKPF-BSIK-BSAK.
    BSIK and BSAK have the same details as BSEG and are use by SAP for reporting purposes.
    Similarly for customer the table are BSID, BSAD and for GL the tables are BSIS and BSAS.
    BSIK will have the open items and BSAK will have the cleared items.
    -Kiran

  • Could not complete the define custom shape command because of program error

    I am using the pen tool to draw a shape and then select it to create a custom shape. I use path: edit - define custom shape = "could not complete the define custom shape command because of program error"
    The error message appears once I click the define button.

    Also, I solved this another way, seems to happen to me often. I click on the path panel, near layers panel and clicked on 'load path as a selection' (3rd icon on bottom from left), then click 'make work path from selection' (4th icon on bottom from left). Then you will see that the whole work area is part of the selection, including your desired shape/path. In order to change this, just select 'path selection' tool and highlight each corner and delete each point from each corner, then you are left with the desired selection to create a shape. I am self taught and this seem unorthodox, but it works.

  • When I click on Define Custom Shape, I get an error message: "could not complete your request because of a program error."

    I'm using Photoshop CC 2014. When I click on Define Custom Shape, there is an error box that says "could not complete your request because of a program error."  How can I solve this problem or work around it? I've looked on the internet for answers but could find no solutions to this. The custom shape tool is 99% of what I use!

    Consider resetting the Pen tool by right clicking here
    and if that doesn't solve the problem a logical next step would be to reset your Preferences.
    To reset Preferences:
    If Photoshop is already open on your screen, close it (Quit). Then hold down Shift+Ctrl+Alt (Win) / Shift+Command+Option (Mac) on your keyboard and start Photoshop.
    A dialog box will pop up asking if you want to delete the existing Preferences file (the "Settings"). Click Yes in the dialog box. The existing Preferences file will be scrapped and a new one will be created.
    By the way, if "The custom shape tool is 99% of what I use!" have you considered Illustrator?

  • How do I save a custom shape to use as a text box?

    I've finally worked out how to define a custom shape. Is there any way to save it and use it in other documents?

    Save the document in which it's defined as a template.
    Every document created from this custom template will embed your custom shape.
    Yvan KOENIG (VALLAURIS, France) mercredi 26 janvier 2011 11:30:30

  • Define custom shape error in Photoshop CC 14.2.1

    whene I try to define Custom Shape I got this message

    Those errors are from February 7, so not helpful.  (and they were probably due to bugs in Generator that got fixed in 14.2.1).
    Hmm, not sure why you aren't getting an error logged.
    And I can't seem to get any errors when defining a custom shape.
    What sort of shape/path do you have selected?
    What sort of document are you using?

  • Is there a way to add shapes to the shape library, and does anyone make a shape library for electronic block diagrams?

    Hello!
    I'm trying to use Pages or Keynote to make electronic block diagrams.  The shapes library looks like it would be perfect for the job, but the shapes are limited.  I know I can make a custom shape, but I live with slight brain damage, which means the mouse is NOT my friend.  If I try to make custom shapes, they look like a kindergartener's scrawl, so that's not a solution.
    All of the online forums I've been to so far say to use Visio (ick!) and if your desired symbol is not there, make it yourself.  Well, several symbols are not there, and the first paragraph explains why this is a non-starter.
    I would gladly pay some reasonable fee for electronic shapes, such as amplifiers, mixers, oscillators, etc. if someone made them.  But from the help file I can't even see a way to add those shapes to the Apple shape library, so I'm not sure, other than copy and paste, how to handle outside shapes.  Copy and paste is pretty labor intensive anyway, but if it's my only option, well, so be it.
    Any suggestions?  Aside from Visio, that is...
    Thanks!
    Jim

    Hi Jim,
    When you say the "Apple shape library" do you mean the Shapes button on the toolbar in Pages?
    I don't think there is a way to add to the Shapes in Pages. However, you can create a custom template with shapes that you frequently use. Save a document with your shapes then Menu > File > Save as Template...
    This will be saved in My Templates folder, and you can open it with Template Chooser. You will still have to Copy and Paste a shape into the document you are working on. No way around that!
    I don't use Keynote, so I may be missing something in your question.
    Regards,
    Ian.

  • Can I buy a MacBook Pro with swedish keyboard in USA and pick it up in New York?

    Can I buy a MacBook Pro with Swedish Keyboard online and pick it up on an Apple Retail store in New york

    This discussion comes as close to give you your answer as you will get here.
    https://discussions.apple.com/message/21374165#21374165
    Best option is to contact Apple Customer Service and pose your query to them.
    Ciao.

  • Pre-order shipment for new IPhone 5 pushed back to 10/5. How can I go to store and pick up rather than wait?

    I pre-ordered shipment of the IPhone 5's 9/14 like many others, and now it pushed back to 10/5. How can I go to store and pick up at upgrade rate rather than paying full price?

    Thanks for the thought... ordered direct from Apple. I'm on AT&T, so I called them to work through their network. They said they couldn't help me until I cancelled my orders through Apple. Talked to an Apple store rep, and they said they had a customer that tried that - cancelled orders, then drove to store only to find they were not eligible for an upgrade. She called AT&T, and they had no solution, and said that sometimes it takes 48 to 72 hours for the system to reinstate upgrade eligibility.....I would have originally ordered from AT&T, but couldn't get into their website, so ordered through Apple - mistake.

  • Define Custom Shape doesn't work in Photoshop CS5

    It seems to be impossible to Define Custom Shape in Photoshop CS5. This option in Edit menu always remains grayed out...
    Can anyone check and see if this is the case in your own installation of the program?
    Very same procedure works in Photoshop CS4 just fine, but not in CS5...

    Hi Fox,
    I think you might just have found a bug there. I've reported it upstairs.

Maybe you are looking for