How can I get the CIAttributedTextGenerator filter to break onto multiple lines? - ios

I'm working on an app that overlays text onto an image. We want to be able to constrain the width of the text and have it break onto multiple lines, much in the same way that UILabel does when we set numberOfLines = 0. In my mind, this should be possible by constraining the extent that the filter has to work within somehow, or by chaining it with a clamp (since the output bitmap is generated lazily.) Unfortunately, nothing I've run into seems to do the trick:
The CIClamp approach generates a nil outputImage when provided a CIVector(cgRect:) argument
There doesn't seem to be a way to specify a CIFilterShape to draw the text within when using the bundled filters
You can provide a CIFilterShape when invoking CIKernel.apply but a) I don't have a custom CIKernel (and am hoping not to write one) and b) I don't have a way to extract the kernel from the CIAttributedTextGenerator filter
I'm resigning myself to manually computing line breaks but it really seems like Core Image ought to be able to handle this use case. Am I just missing something?

Related

Conditional formatting color scale - second highest value as maxpoint?

I have a table with values in it. I want to be able to immediately spot the cells with the biggest values. Using the color scale tool works nicely as demonstrated below
However, with my real data, there are a few cells that have huge values in it - these then raise the maxpoint so high that the formatting kind of breaks for the other values since in relation to the maxpoint, the other values are very small, making the colors among them almost indistinguishable.
I have obtained the second-highest value by doing =large(A1:C3,2) in an unrelated cell - however I seem to be unable to reference that cell in the Maxpoint setting. Is there a way?
Another idea was to manually set up a color scale that is more logarithmic in its curve but this really isn't a nice option I think. The only option that's left that I can think of is to dynamically color the cells via a script - is there already an easier or existing solution?
try like this:
=LARGE($A$1:$C$3; 2)

How to always show Sirius Label in foreground

For the context, I'm working with Capella, an Eclipse RCP application based on Sirius (hence, EMF, GMF and draw2d). This application is used for MBSE, that basically means diagram representations for industrial systems.
I'm developping an add-on (viewpoint) to display custom labels next to diagram elements. These diagram elements are, to put it simply, boxes inside boxes. My problem is that usually the label text is larger than the space between a box and its container, so the label gets hidden. What I need is these labels to always be in foreground. As I'm more used to web development, what I'm looking for would be the equivalent of the z-index CSS property.
Currently I have no idea of how to achieve this, I'm using a custom .odesign that allows me to control some rendering options, like labels text, the color of some elements or to add decoration, but I dont think its the way to go for my problem. Maybe I should use a custom EditPart or a custom StyleConfiguration (I already used these components for other projects) but I have no clue where to start for this issue.
Any leads will be greatly appreciated.
We recently did this kind of changes to keep some labels in Sirius Sequence diagrams always on top: the combined fragments are placed behind the lifelines (z order) but we wanted to keep the labels of the CombinedFragments visible event their bounds intersects Lifelines, Executions or States).
This has been handled in Bug 564239 for Sirius 6.3.2 (used in Capella 1.4.1).
You could find some hints the bugzilla (Gerrits and commits can be retrieved from the See also section).
In Sirius Sequence diagram , we use org.eclipse.sirius.diagram.sequence.ui.tool.internal.layout.SequenceZOrderingRefresher to control the z-order of CombinedFragments : all the figures that composes them comes from some expressions in the odesign, and synchronization with the Capella model for exemple.
But in your case you want to control only the label, so it must not be dealt on the edit par level, but on the figure one. The "overlay" layer and figure lead might be a good one.
Do not forget another thing: in GMF/GEF, the labels of an element is displayed/shown/rendered/visible if it fits to the visible area of the parent container: in the case of a node in a container with scrollbar, the visible are will impact the visibility of the sub nodes (extended to their border nodes, edges, labels, ...)
Regards
Maxime

How to access a layer inside UIView custom class generate with Paintcode?

I'm using Paintcode V3 and last Xcode for my project.
In Paintcode I draw a red path, kind of "clock hand" with a radius variable to be able to rotate it.
In my Xcode project, this custom UIView is added to a main view.
When the red path is rotating, I need to know when it intersects with another element of the view.
I tried:
if self.redPathView.frame.intersects(self.anotherView.frame) {
//do something...
}
but it can't work because redPathView is the entire Paintcode canvas (the square frame) and not only the red path.
I'm searching a way to access to the red path of my view.
Interesting problem.
I don't think there is a way to do exactly what you are looking for...
Like you mentioned, when we use PaintCode, our custom drawings become an entire UIView.
We can't access its specific elements (like your redPathView).
(I'm favoriting this question in case anyone knows if we actually can. I may be wrong.)
Anyway, there is a workaround. You could use PaintCode itself to tell you when "collisions" happen. Of course, then you would need to draw everything there... And implement some sort of internal control that would make sense to you.
For example, in the picture below I created this "clock hand", with functions to detect when the red thing touches other UI elements (key point there is the touchedElementID expression -- observe how it updates itself with the "ID" of the rectangles):
There are some issues you may find with this approach, for example the need to know the exact position of other elements on the screen and possibly complex ternary constructions like:
(rotationSanitized <= -352 || rotationSanitized >= -8) ?
1 :
(rotationSanitized <= -82 && rotationSanitized >= -98) ?
2 :
(rotationSanitized <= -172 && rotationSanitized >= -188) ?
3 :
(rotationSanitized <= -262 && rotationSanitized >= -278) ?
4 : 0
Also, how to "export" and consume this information along with the StyleKit in Xcode?
The trick I did was to add an empty (no Fill, no Stroke) UI element in PaintCode and associate the touchedElementID expression result to the alpha value of the element.
This way I could access the expression in my custom view, for example via StyleKit.touchedElementID. But that introduces a new problem since now I have to change the generated StyleKit every time it is exported (two lines of code, but still). That is kind of a fragile solution.
However, if you are ok with that, then it's just a matter of consuming this new information...
For that I created a protocol, so my ViewController can act as the delegate of my custom view, and perform whatever it needs to do when the most internal UI elements in PaintCode are "touched".
Here is the final result:
Finally, check this project in GitHub with all the code and samples.

Lua script for iOS getColors within range?

I am trying to capture the pixel color of a specific letter in a font within an iOS app. I'd then use that color in an if/then statement to determine the next action of my script. I'm finding no easy way to determine if the color/colors I'm finding are the right ones. Here's my current process: I start recording my inputs and continuously click around the letter. I end up with something like touchdown(123,456). I change that to alert(getColor(123,456)) and run, which produces a popup that tells me the color such as 3094841 (not sure why the colors are in numeric format, but they are). I do this for each touchdown line that is captured. The problem is, I don't know an easy way to determine which color is the small letter I'm trying to tap.
Is there a lua function that will capture and display a range of colors between 2 points? If there were, I could see the commonality of all of the colors within the 2 points and make at least an educated guess as to which is the color in the font. Or even more useful - is there a tool I can use to type in the color I'm getting back and have it display the corresponding color, so I can compare them. That'd be the easiest. Hope this makes sense. Any help would be awesome. In case it matters, I'm using Autotouch 8 on an iPhone 5.
TIA
I use this function often in my games.
I find the easiest way to get a color you want to execute every single time is to take a snap of the screen you're checking and then use the helper on getColor(x, y)
And you can use this to alert your color.
local color = getColor(x, y)
alert(color)
-- You can also use:
log(color)--this one keeps it in your log in case you can write it down immediately.
To use this in an if/then statement
function = namedfunction()
local color = getColor(x, y)
if color == YOURCOLOR then
else
end
end
namedfunction();
Note that I have the iPhone 5 iOS 8.3 and I have the most recent AutoTouch from Cydia. If you don't have the helper when you're scripting it might be worth it to check if Cydia offers a capatable version.
Edit: I am running version 3.5.3-8 of Autotouch.

Checking location of word range relative to the page

I am writing a vba macro that checks that word documents are formatted correctly to meet certain specifications. One of the things I have to check for are the left margins of each line - different paragraphs are supposed to have different first indents and hanging indents depending on the context. This should be as simple as checking the style, but unfortunately it is not - some of the documents use styles to change the indents, but others use manual spaces and tabs to position the text correctly. So I need some way to check the actual physical position of the first physical character in each Document.Paragraphs. I have no problem getting a range with the first visible character in the paragraph, but I'm not sure about getting the distance from the margin (or from the left side of the page - doesn't make a difference because the margins are consistent).
I found the Window.GetPoint method, but I'm nervous to use it, because that is based on the actual physical location on the screen. This macro is going to be used on different computers, with different versions of word, and I'm not sure about how it is affected by other view settings (like print layout, zoom, etc.) Is there a consistent way to use this method to determine the distance from the margin?
The other method would be (because all of the documents are in Courier New 12) to look at the firstindent property of the style, and the count manually all of the spaces and tabs (but that would need to take into account tabstops). This I'm also not sure how to do.
I would think that there should be a much simpler way of doing this, but I can't find it, so if anyone has any suggestions I would really appreciate any help.
It was there after all! Range.Information(wdHorizontalPositionRelativeToPage)

Resources