Aligning Object to Horizontal & Vertical Center Center of Another Object

Hello,
I've looked through the DOM and at the various methods and properties of various Javascript classes, but didn't see an obvious way of aligning one object's center to another object's center (particularly a Text Frame to a Group Item or Path Item). I'd have expected this to be pretty routine, so forgive me if I've overlooked the obvious (both in the documentation and on this forum).
Thanks!
Ben

OK, well I guess I just needed to think a bit more. The answer I came to just required the use of some math.
Basically,
object_to_center.position[0] = object_to_center_to.position[0]+object_to_center_to.width/2-object_to_center.width/2; //X coordinate of object to center
object_to_center.position[1] = object_to_center_to.position[1]-object_to_center_to.height/2+object_to_center.height/2; //Y coordinate of object to center
Seems you get the center point somewhat indirectly, but at least you can get it.

Similar Messages

  • Why does Vertical Align Center align objects along the horizontal?

    And why does Horizontal Align Center align objects along the vertical?
    -g-
    P.S. Please please please make the Eydropper tool available by function key so I can toggle to it while using the Text tool. Please!

    g,
    but when I select two objects and click the vertical align button they snap to an invisible horizontal line
    This is (almost) identical to:
    Because (the centres of) vertically aligned objects will be on the same horizontal level/line.
    And that is just one way of expressing what vertical alignment means. Here are a few others:
    Their centres have the same height,
    Their centres have the same Y value on the Artboard/Workspace,
    In all cases, you can draw a horizontal line through their centres.
    Mathematically, Y = C (Y is a constant value C) is the equation for a horizontal line.

  • Is there a way to vertically center text / elements?

    Please help on this

    Hi Gupevieira,
    This would depend as what and where you exactly want to align page items. Examples being:
    1) To align the content on the Muse canvas, you may refer to the following link:
    How do you center objects and or a website vertically and horizontally in Muse?
    2) To fix certain content on the browser window, you may center it as in the above scenario, and use the Pin feature to fix it in the browser.
    3) To align some text vertically in a text frame, you may refer to:
    Need Help with Text Alignment
    4) To align with reference to other content, you may you the Align panel (Window->Align)
    Additionally , you can use padding/gutter value for spacing in respect to alignment in spacing panel, similarly Align panel can be used to align objects on page accordingly.
    If this is not the answer you are looking for then please provide more details as what you are trying to achieve , screenshots would help.
    Regards
    Sonam

  • How to Vertically center dynamic text?

    I am trying to vertically center and wrap text within a Text div. I have figured out how to center text if it is a single line, but the text that I am using will be diffrent for each user depending on what language they view the page in. How can i make sure that text is always vertically centred and wrapped regardless of how long it is?

    Could you do this with css? There is a css attribute display:table that allows you to set the paragraph attribute to align to themiddle of a region. See: http://css-tricks.com/vertically-center-multi-lined-text/
    Hope that helps.

  • Vertical Center a Page

    I can horizontally center a page with:
    $("#Stage").css("margin","auto")
    How can I vertically center a 960px x 580px Edge Page (Stage)?
    Thanks for any help

    Hi Mario,
    The only way to achieve this is by using anchors. There is no way in Muse to do so. For more info, Please refer to the following link Re: How can I have an anchor used as my home page?
    Regards,
    Aish

  • .oneColFixCtrHdr - Vertically center container no matter what the window size is

    The site is leescottfineart.com
    I want the container to vertically center no matter what the viewer's window size is.
    Any suggestions - thanks, Patti

    Vertical centering is a Print concept; not appropriate to web design except for special situations like Splash/Intro pages or business cards.  See demo below:
    http://alt-web.com/TEMPLATES/vertical-center.html
    Horizontal centering is all you need in most situations.
    If you feel the page would look better with some top margins and padding, add them to the body CSS code.
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    http://alt-web.com/
    http://twitter.com/altweb

  • How to set default for "Horizontal / Vertical Alignment"?

    Hi,
    is there somewhere a setting to change the default of the "Horizontal / Vertical Alignment" property for an item label? I don't like the "Right" alignment and I have to change it each time when I create a new item.
    Thanks
    Patrick
    http://inside-apex.blogspot.com

    Yes, this is one of (many) cases where a Bulk edit feature in the Builder would be very useful. There have been some discussions about this and hopefully the APEX team is considering these for the next release.
    Having said that, I frequently find myself taking a full app export and editing the SQL file in my favorite text editor (Vim) and making these little changes.
    This is NOT to be done lightly, see the caveats and disclaimers at Re: htmldb application Disabled(on updation of FLOWS_020000.WWV_FLOW_STEP_I
    As always, take a backup of the file before modifying it and save it so you can revert back to it if something goes wrong.

  • In ALV I want to align Top-Of-Page in Center which contains some TEXT

    Hi Abap Gurus',
                          In ALV's i want to align TOP-OF-PAGE in center.
    Which contains some TEXT.
    Can you please help me out.
    Points will be Given.
    Many thanks
    Anil Roy.

    hi anil
    The header line is always left-justified .
    We basically have three options for formatting :
    S , A and H.
    every line in Alv top-of-page is of 60 char length(slis_listheader-info).so i think the only option we have is to add required spaces to the left and display the required string
    regards
    navjot
    reward if helpfull

  • How to vertically center InlineGraphicElements?

    Hi all,
    I'm trying to extend the InlineGraphic TLF example to insert images of varying sizes, but vertically center them in the text Flow.  I'm having trouble figuring out the correct parameters to properly center the element.  I've been playing with alignmentBaseline & dominantBaseline w/ IDEOGRAPHIC_CENTER, but I don't get very promising results.  Here's a screen shot of where I'm at:
    Notice the blue box(added in post), the text MESSUP is being placed on the same line as the Lorem Ipsum text(in the string, it's Donec MESSUP).  Also, the selection box (Ctrl+A) shows breaks in the text layout.  It seems like the boxes should be shifted up.  This may be as designed, if so, how do I compact/shift the boxes up?
    For contrast, this is what it looks like without the centering:
    Source:
    package
        import flash.display.Sprite;
        import flash.text.engine.TextBaseline;
        import flashx.textLayout.container.ContainerController;
        import flashx.textLayout.edit.EditManager;
        import flashx.textLayout.elements.InlineGraphicElement;
        import flashx.textLayout.elements.InlineGraphicElementStatus;
        import flashx.textLayout.elements.ParagraphElement;
        import flashx.textLayout.elements.SpanElement;
        import flashx.textLayout.elements.TextFlow;
        import flashx.textLayout.events.StatusChangeEvent;
        import flashx.undo.UndoManager;
        [SWF(width="760", height="590", backgroundColor="0xCCCCCC", frameRate="30")]
        public class inliner extends Sprite
            protected var textFlow:TextFlow;
            public function inliner():void
                var elements:Array =
                    "Lorem ipsum dolor", null,
                    "sit amet, consectetur", null,
                    "adipiscing elit. Mauris eu odio nibh. Duis", null,
                    "scelerisque mattis risus, vitae viverra", null,
                    "ipsum vehicula non.", null,
                    "Donec MESSUP"];
                textFlow = new TextFlow();
                textFlow.fontSize = 34;
                textFlow.backgroundColor = 0xFFFFFF;
                textFlow.backgroundAlpha = 1;
                var imageSize:uint = 20;
                var paragraphElement:ParagraphElement = new ParagraphElement();
                textFlow.addChild(paragraphElement);
                for(var i:uint = 0; i < elements.length; ++i)
                    var obj:* = elements[i];
                    if(obj is String)
                        var string:String = obj as String;
                        var span:SpanElement = new SpanElement();
                        span.text = string;
                        paragraphElement.addChild(span);
                    else if(obj == null)
                        var inlineGraphic:InlineGraphicElement = new InlineGraphicElement();
                        inlineGraphic.width = imageSize;
                        inlineGraphic.height = imageSize;
                        imageSize += 20;
                        inlineGraphic.source = "http://www.adobe.com/shockwave/download/images/flashplayer_100x100.jpg";
                        // comment out to change back to good looking text
                        inlineGraphic.alignmentBaseline = TextBaseline.IDEOGRAPHIC_CENTER;
                        inlineGraphic.dominantBaseline = TextBaseline.IDEOGRAPHIC_CENTER;                   
                        paragraphElement.addChild(inlineGraphic);
                // event sent when graphic is done loading
                textFlow.addEventListener(StatusChangeEvent.INLINE_GRAPHIC_STATUS_CHANGE, graphicStatusChangeEvent);
                const bufferX:Number = 50;
                var sprite:Sprite = new Sprite;
                sprite.x += bufferX;
                addChild(sprite);
                textFlow.flowComposer.addController(new ContainerController(sprite, 760 - bufferX * 2, 590));
                // this call compose but the graphic hasn't been loaded from the source URL yet.
                // The actualWidth and actualHeight are zero. 
                refresh();
                var em:EditManager = new EditManager(new UndoManager);
                textFlow.interactionManager = em;
                textFlow.interactionManager.setFocus();
            protected function graphicStatusChangeEvent(e:StatusChangeEvent):void
                // if the graphic has loaded update the display
                // actualWidth and actualHeight are computed from the graphic's height
                if(e.status == InlineGraphicElementStatus.READY || e.status == InlineGraphicElementStatus.SIZE_PENDING)
                    refresh();
            protected function refresh():void
                textFlow.flowComposer.updateAllControllers();

    Cannot, really.
    Read this -
    http://www.apptools.com/examples/tableheight.php
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Reese" <[email protected]> wrote in message
    news:eh34gg$rvh$[email protected]..
    > How to vertically center a div? :-S
    >

  • - How to vertically center a div?

    How to vertically center a div? :-S

    Cannot, really.
    Read this -
    http://www.apptools.com/examples/tableheight.php
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================
    "Reese" <[email protected]> wrote in message
    news:eh34gg$rvh$[email protected]..
    > How to vertically center a div? :-S
    >

  • Indesign CS5 - how to align objects

    Dear All,
    I have a problem with Indesign that is present from CS2 trough CS3 & CS4 version. I thought that CS5 version finaly will solve this issue, but it seems to me that nothing changed.
    When we have to align two objects lets say in Illustrator,  we may always mark the reference object by second click (then it is locked). In different software the sequence of marking objects for aligment is important (even better solution in my opinion than in Illustartor). But in Indesign things work different. If we align objects to the top - the most top object is reference. When we align to the left the object most to left is the base for aligment.
    I think that everyone learned to live with that by right placing the objects before aligment. Sometimes by centering (in past versions) we were forced to lock one of the objects before aligment. But now in CS5 locked object is not selectable. Besides that I never liked this long "work around" method.
    My question is how to easy align vertical centres of the objects shown on the picture below when I want object A to stay on place and object B to be centered to A. I don't want to use smart guides.
    Paul

    Hello Peter,
    thank you for fast feedback. I appreciate it.
    I don't want to use smartguides because when there are more objects around it will be confusing to guess if you have right center or not.
    Changing preferences for locked objects will not help much I guess. I like the way the locked objects are unselctable now and of course, as you mentioned, it is time consuming way to go.
    The case is, that I would like Adobe to add this issue to the wish list. If this "double click" way is good for Illustrator, why it is not implemented in Indesign, forcing users to use some magical, time consuming, workarounds.
    To be honest, I hopped that I miss the point in this case and someone will tell me some obvious shortcut to use by selecting the objects to get the things right.
    Paul

  • Illustrator CS6 - How do I align objects into a grid?

    I am a fan of pixel art and the Live Paint Bucket tool in Illustrator CS6 (I don't really like using Photoshop for this because it is more limited in this field). I have made a thing in pixel art, but I noticed that things weren't exactly lined up. See the picture:
    It has messed up the paint bucket tool a lot. Can I align these so that they make a grid? I have tried the Align tools, but I end up with stuff like this:
    Horizontal Distribute Center
    Can I do this (without changing the document grid)? I have tried this script, but I get this:
    Note: My grid is not in proper layer order.

    easyaspi,
    How about using Align to Pixel Grid?
    You may select everything and tick Align to Pixel Grid in the Transform palette, and also tick Align new Objects to pixels Grid in the Options flyout.
    You may also use a document type with that as default (RGB for web and the like).

  • How to place a JPanel at the center of another JPanel?

    Can anyone tell me how to place a JPanel inside another JPanel? The first JPanel consists of three JPanels each consisting of a label&textfield and are placed using BoxLayout. The second JPanel is a big blank screen. So, i would like to put the first JPanel at the center of second JPanel(horizontally & vertically). The problem is that i don't have any other component. So,if i try to use FlowLayout, i am able to put it at the center(horizontally, not vertically) only on the top edge. I tried to use BoxLayout. But, i couldn't(as i don't have any other elements). I tried to create some blank elements. But, they are messing up the elements of my JPanel. Any cluesssssssss??????????

    import java.awt.*;
    import javax.swing.*;
    public class CenteredLayout
        private JPanel getPanel()
            GridBagLayout gridbag = new GridBagLayout();
            GridBagConstraints gbc = new GridBagConstraints();
            gbc.insets = new Insets(2,2,2,2);
            JPanel p = new JPanel(gridbag);
            addComponents(new JLabel("label 1"), new JTextField(8), p, gbc);
            addComponents(new JLabel("label 2"), new JTextField(8), p, gbc);
            addComponents(new JLabel("label 3"), new JTextField(8), p, gbc);
            JPanel panel = new JPanel(gridbag);
            panel.setBackground(Color.pink);
            gbc.anchor = GridBagConstraints.CENTER;
            gbc.insets = new Insets(0,0,0,0);
            panel.add(p, gbc);
            return panel;
        private void addComponents(Component c1, Component c2, Container c,
                                   GridBagConstraints gbc)
            gbc.anchor = GridBagConstraints.EAST;
            gbc.gridwidth = GridBagConstraints.RELATIVE;
            c.add(c1, gbc);
            gbc.anchor = GridBagConstraints.WEST;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            c.add(c2, gbc);
        public static void main(String[] args)
            JFrame f = new JFrame();
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(new CenteredLayout().getPanel());
            f.setSize(400,400);
            f.setLocation(200,200);
            f.setVisible(true);
    }

  • Align objects to text paths?

    Hi all,
    I don't know if this is possible at all in Illustrator, but I want to align objects to text paths. Look at the following example to get an idea what I mean.
    I start with something like a circular hierarchy, that I get as an output from another program. These are only lines and text. Now I want to add a flag behind the text. This flag should have the same orientation as the text path.
    As this hierarchy is actually pretty big (this is only a snippet), I don't want to rotate all the flags manually. I tried to do it manually with the below example, but it still doesn't looks right...
    Does anyone know, if there is a proper method to rotate the flags according to the orientation of the text paths in Illustrator? Any help is much appreciated!

    I don't know of more automated way  than doing it manually. However you can make the rotation precise using the smart guides. Assuming the text is live (not outlines), this is how I would do it:
    Make sure on the View menu, there is a checkmark in front of Smart Guides (Ctrl+U)
    With a text object selected, pick the Rotate tool (R), find, and click the anchor point of the text object which will be at the left bottom side if the text is left aligned. The Smart Guides will show an "Anchor" label when the mouse cursor is over it.
    Then, away from the Anchor point, click and drag the path of the text object to rotate it until aligned horizontally or vertically to the artboard which will be indicated by the Smart Guides displaying a straight horizontal or vertical line.
    Hold Ctrl key down temporarily to switch to a selection tool and click with it the flag you want to rotate.
    Release the Ctrl key to get back to the Rotate tool and press the Enter key on your keyboard to get the Rotate dialog.
    Change the Angle value to positive if it is negative and negative if it is positive and press the OK button. On a pc you can do all of this step with three keyboard keys instead of the mouse if you press first the Home key, then Delete or Minus for changing the value to positive or negative, and finally press Enter to apply and close the dialog. The flag is now rotated with the same angle as the original orientation of the text.
    Cut (Ctrl + X) the flag, and Undo (Ctrl + z) a few times until you go back to the original orientation of the text.
    Paste (Ctrl + V) to get a copy of the rotated flag and position it in place. I can see that your skills with position the flags are much better than aligning the orientation and I don't think you need more complicated way of doing it.

  • Align objects grayed out

    I placed an image in my Pages document, and I would like to center it. I clicked on it, went to arrange, and then align objects. All of the choices are grayed out. Any ideas why?

    Choose at least two objects, they align against each other.
    If you just want it to align to the cntre of the pahge just drag it till an alignment line shows up.
    Either that or you object is inline in the text and not floating.
    Peter

Maybe you are looking for