EaselJS way to change default pivot? - createjs

Pivot of stage is set to Left Top corner of canvas but I want Left Bottom corner.
So then up is +y and right is +x
Is this possible?

It is not advisable to transform the stage -- there are some issues with how mouse coordinates are transformed.
Put your contents in a Container instead
Set the coordinates of the container to the stage width/height
Move your contents into negative x/y
If you absolutely must transform your stage, you can set the regX and regY to the stage width/height. It will move the contents, so you will have to counter-position the contents so they display properly.
Hope that helps!

Related

Why position of mouse always take absolute position and colour at position command always return relative colour of window?

I want to take the colour of the window at some position, I had tried to use both absolute position and relative position of the mouse(when the question dialogue box pops up) and with both the arguments of colour position relative true and false but with every condition it always takes the absolute position of mouse and return the colour of the relative window.
color position 762⫽485 relative false
dialog ♥result
As g1ant window is white it returns FFFFFF but my desktop is red.
As you have noticed, the robot is getting the colour of the G1ANT.Robot window and not the desktop. According to the manual:
The color command retrieves the red, green and blue (RGB) color values of the pixel at the specified coordinates
And about the relative argument:
position needs a value representing pixel coordinates and
relative defines if these coordinates are relative to the upper left
corner of the active window (by default) or absolute on the screen
(also measured from its upper left corner).
So absolute position means that wherever the window is, the colour will be get relative to the top left corner of the screen. relative position means that the colour will be get relative to the top left corner of the active window.
In your example it doesn't matter if your desktop is red because, I assume, G1ANT.Robot is focused when you launch your script.
You can either:
Use the WIN+D shortcut which will minimize all opened windows (show desktop):
color position 762⫽485 relative false
keyboard ⋘WIN+D⋙
dialog ♥result
Leave the script as it is but move the G1ANT.Robot window to some position where it doesn't cover the 762⫽485 position that you want to get the colour from.

How to reposition non reliative multiple labels of edges in JGraphX

In a graph, I have edges that have more than one label (multi labels): one label is beside the source cell and another one beside the target cell. Both labels are created as child vertices of the edge. For correct positioning adjustement reasons, these labels do not have their geometry set relative (to the edge). When generating the edges, labels are correctly positionned: I use the mxGraphView.getPerimeterPoint() and an few adjustements to position the source and target labels.
When moving a cell using the mouse drag, I need to reposition these labels. For the moment I have tried to react to graph events (mxEvent.CELLS_MOVED, mxEvent.MOVE_CELLS) or model events (mxEvent.CHANGE) registering either a graph or a model listener.
However, the getPerimeterPoint function uses an mxCellState (not an mxCell) obtained through the graphView (graph.getView().getState(cell)) to do the calculation and this cell state mxGeometry is based on the previous position of the cell.
Is this solution based on events the correct way of doing this?
And if yes, should I rewrite completely the getPerimeterPoint (and functions used in it) to use the mxCell returned by the event (event.getProperties("cells")) whose greometry is correct rather than the mxCellState? Or is there a technique to get the cell state corresponding to the end of the current move operation without messing up the whole graph update process?
Any help or advice appreciated, thanks.

vb.net check if two panels are overlapping

I have a panel that I can move around with a drag/drop system. I would like it to snap to a certain position when it is drug on top of another panel. How would I check if the panels are overlapping?
To simply check if panels are overlapping, use Rectangle.IntersectsWith.
If you need to know how exactly they are overlapping, use Rectangle.Intersect.
In both cases you need to be using Panel.Bounds as arguments, so either
Dim b As Boolean = panel1.Bounds.IntersectsWith(panel2.Bounds)
or
Dim r As Rectangle = Rectangle.Intersect(panel1.Bounds, panel2.Bounds)
Then check if r is large enough for drag and drop, for example.
In order to check if panels are overlapping, you can check if panel bounds overlap:
Dim arePanelsOverlapping = panel1.Bounds.IntersectsWith(panel2.Bounds)
To snap to the position, you can also make use of Top, Left, Bottom and Right properties.

How to move a rotated shape to a specific location in excel 2010 using vba

I've written some VBA code that automatically creates a chart. One of the axes on this chart doesn't use normal labels but a graphic. I've stored the graphic as an image and I use the .Copy and .Paste methods to get a copy of this image onto the chart.
Here is where it gets confusing. I need to rotate the image to get it aligned with the axis (using the .rotation property). But when I set the .top and .left properties the shape doesn't end up where I would expect. In fact setting the properties to 0 and 0 doesn't do what I would expect either. I've tried changing the order of the way I set the properties on the image object but it only appears in a different (wrong) location.
I'm sure I'm missing some vital aspect of how VBA/Excel is placing the object relative to what I'm setting the top and left properties to. Basically my goal is to make the image on the left side of the chart with the same width as the plot area's height (since the image is rotated I theorize this will make it the same size).
This code does not work:
Sheets(ImageSheet).Shapes("agreement").Copy
c.Chart.Paste
c.Chart.Shapes(1).Rotation=270
c.Chart.Shapes(1).width = c.Chart.PlotArea.height
c.Chart.shapes(1).left = 5
c.Chart.Shapes(1).top = c.Chart.PlotArea.top
I've also tried this code
c.chart.Shapes(1).top = c.chart.PlotArea.top + c.Chart.PlotArea.height
because I thought maybe it was calculating the "top" as the upper-left corner of the image object when it is not rotated (rotating 270 degrees makes this point in a place where it should align with the bottom of the plot area). But that doesn't do what I expected either.
The image is a skinny rectangle that acts as a label for the axis. The chart will end up being laid out like this: http://imgur.com/NrSXR and the axis label image would be something like this http://imgur.com/08EWU
What am I missing here?
Is it possible for you to align your chart into a position where the shape could rest align/on a cell?
IF YES then here is a suggestion:-
You could position shape into a cell. Then adjust the size to what you need. And rotate.
Then change its bring forward property be shown on the Chart.
Next Group Chart and the Shape
PS: I recorded a macro. However it's best if you could show us what your the exact picture (=how your sheeet/chart/image should look like) of your question.
I ended up rotating and resizing the image before copying and pasting to the chart and then positioning it. I had to use the IncrementLeft and IncrementTop methods rather than setting the left and top properties directly because that did not have the desired effect.
When doing the paste into the chart the object always ended up in the upper left hand-corner so I could increment to the left by the small amount I wanted as a margin I wanted there and increment the top by the value of PlotArea.top to align it with the plot area.
I was also surprised that when creating the copy of my image it retained the "name" i referred to it as when I copied it to the new sheet and chart. This was especially useful for positioning the image once it was on the chart.
I also needed execute this code at the very end of my procedure, after everything else had been positioned and aligned, or when I positioned the data labels for one of my series they wouldn't appear correctly.
Here is the code that I ended up using:
'make a copy of the label image and refer to it with a variable for convenience
Sheets(ImageSheet).Shapes("maturity").Copy
i = Sheets(ImageSheet).Shapes.Count
Sheets(ImageSheet).Paste
Dim axisImage As Shape
Set axisImage = Sheets(ImageSheet).Shapes(i + 1)
'rotate and resize the image
With axisImage
.Rotation = 270
.width = c.Chart.PlotArea.height
End With
'cut and paste the new image to the chart
axisImage.Cut
c.Chart.Paste
'position it in the chart using IncrementTop and IncrementLeft because setting the properties directly does not have the desired effect
c.Chart.Shapes("maturity").IncrementTop c.Chart.PlotArea.top
c.Chart.Shapes("maturity").IncrementLeft c.Chart.PlotArea.left - c.Chart.Shapes("maturity").height

Why can't I set DataLabel.Position to xlLabelPositionCustom?

I am working with vb.net and excel 2007 to create some graphs for myself. I wanted to set the datalabel positions to a custom value since the default above position (xlLabelPositionAbove) causes the labels to clash with error bars and the default option for a side (such as xlLabelPositionRight) may leave the label over another point or other errorbar. Due to this, I wanted to set the label to a custom position where it is off to about a 45 degree angle to the top right (like right in the middle of where the default above and right positions would place it).
I tried doing this by adjusting xlMySeries.Points(index).DataLabel.Top and xlMySeries.Points(index).DataLabel.Left at first, however I ran into an undescriptive error leading me to believe I was not doing things correctly. I then thought to try setting xlMySeries.DataLabels.Position = xlLabelPositionCustom and then adjusting top and left. However, to my surprise, I could not even change xlMySeries.DataLabels.Position to xlLabelPositionCustom!
Whenever I try to adjust top, left, or the position to certain datalabel positions, I get HRESULT: 0x80004005 (E_FAIL), which I have generally found to mean "You are doing it wrong" in my experience so far with excel. I cannot set the position member to custom, or anything other than just above, left, right, center (so not bestfit, custom, or any inside___ one)
Any idea why I cannot set the position property to what I need it or otherwise change the position of my datalabels? I just need SOME way to adjust the positioning of my datalabels to a custom psoition (or position other than above, left, right, center, bottum). Thanks in advance!
You can set positions only to whose which you can see on the Data Label properties window.