How to set partial text as as bold font to LabelField in Blackberry? - blackberry

I don't know how to set partial text as a Bold to LabelField in Blackberry.
Kindly refer the attached image,

This example should contain everything you'll need. Your code should look something like this:
String copyText = "Tap NEXT to proceed";
Font[] fonts = new Font[2];
fonts[0] = Font.getDefault();
fonts[1] = Font.getDefault().derive(Font.BOLD);
int[] offsets = new int[4];
offsets[0] = 0;
offsets[1] = "Tap ".length
offsets[2] = "Tap NEXT".length;
offsets[3] = copyText.length();
byte[] attributes = new byte[3];
attributes[0] = 0;
attributes[1] = 1;
attributes[2] = 0;
RichTextField textField = new RichTextField(copyText, offsets, attributes, fonts, NON_FOCUSABLE);
add(textField);

Related

Adding Checkboxes to Vaadin Grids

I have constructed a Grid in Vaadin 14 using a parser to extract from files as shown below:
Grid<String[]> grid = new Grid<>();
try {
List<String[]> entries = reader.readAll();
// Assume the first row contains headers
String[] headers = entries.get(0);
for (int i = 0; i < headers.length-1; i++) {
final int columnIndex = i;
String header = headers[i];
String humanReadableHeader = SharedUtil.camelCaseToHumanFriendly(header);
grid.addColumn(str -> str[columnIndex]).setHeader(humanReadableHeader).setSortable(true).setWidth("100px");
}
grid.setItems(entries.subList(1, entries.size()));
What I want to do next is add a CheckBox to every row that would return a visualization of the data in the corresponding row. So my question is two-fold:
Is there a function that already exists to emulate this behavior via clicking anywhere on a row?
If not, what would be the best way to initialize a Grid to accommodate this?
Simply add a component column:
Grid<String[]> grid = new Grid<>();
try {
List<String[]> entries = reader.readAll();
// Assume the first row contains headers
String[] headers = entries.get(0);
for (int i = 0; i < headers.length-1; i++) {
final int columnIndex = i;
String header = headers[i];
String humanReadableHeader = SharedUtil.camelCaseToHumanFriendly(header);
grid.addColumn(str -> str[columnIndex]).setHeader(humanReadableHeader).setSortable(true).setWidth("100px");
}
// Here goes your checkbox column
grid.addComponentColumn(item -> {
// Create the checkbox
}).setHeader("<the header>");
grid.setItems(entries.subList(1, entries.size()));

how to create a light font from a preferred font?

I'm trying to get a "light" weight font from a UIFontTextStyle font style.
Whatever the code (on stackoverflow or in the doc), i always get a "normal" weight font.
For example:
var descriptor = UIFontDescriptor.GetPreferredDescriptorForTextStyle(UIFontTextStyle.Caption2);
att = descriptor.FontAttributes;
att.Traits = new UIFontTraits {Weight = (float?)UIFontWeightConstants.Light};
font = UIFont.FromDescriptor(descriptor, 0);
//t = font.DebugDescription;
returns a normal weight font.
I found a solution. It may help someone.
var style = UIFontTextStyle.Caption2;
var descriptor = UIFontDescriptor.GetPreferredDescriptorForTextStyle(style);
var font = UIFont.FromDescriptor(new UIFontDescriptor(new UIFontAttributes
{
Family = descriptor.Family,
Traits = new UIFontTraits
{
Weight = (float)GetFontWeight(UIFontWeight.Light)
}
}), descriptor.PointSize);

Range Slider issue in Xamarin iOS

I've used the Xamarin Range Slider component for a two way slider in my app but it is raising a random exception "Value cannot be null.Parameter name: image". But the range slider have no such image parameter or property. And I haven't found any work around yet. Any help or suggestion would be highly appreciated.
Thanks in advance.
Update 1:
Here's my code snippet where I've used this Range Slider to represent budget range in my app. Do have a look and tell me if I'm doing something wrong:
rangeSlider = new RangeSliderView {
Frame = new CGRect (lblMinValue.Frame.X, lblMinValue.Frame.Bottom, btnBudgetPlan.Frame.Width, 15),
AutoresizingMask = UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth,
TintColor = UIColor.Green,
};
rangeSlider.MinValue = 0f;
minBudget = rangeSlider.MinValue.ToString ();
//if (maxRange == null && budgetList != null)
rangeSlider.MaxValue = Convert.ToInt32 (maxRange, CultureInfo.InvariantCulture);
maxBudget = maxRange;
rangeSlider.LeftValueChanged += value => {
doneButtonDidPressed ();
var intValue = (int)value;
lblMinValue.Text = intValue.ToString ();
minBudget = intValue.ToString ();
};
rangeSlider.RightValueChanged += value => {
doneButtonDidPressed ();
var intValue = (int)value;
lblMaxValue.Text = intValue.ToString ();
maxBudget = intValue.ToString ();
};
viewBudget.AddSubviews (btnBudgetPlan, tableBudgetPlan, lblMinValue, lblMaxValue, rangeSlider);
I was having the same issue in xamarin forms. Updating the packages helped me.

Slice image and then combine slice into one image in Magic.NET

I have one image and i want to split this image and adding some extra to each split and then combine all image into one image.so i write this code :
public void Slice()
{
using (MagickImageCollection images = new MagickImageCollection())
{
int overlap = cmtopx(1.1f);
int sliceSize = cmtopx(11.3f);
for (int i = 0; i < 8; i++)
{
MagickImage currentSlice = new MagickImage();
Rectangle rect = new Rectangle(i * sliceSize, 0, sliceSize + overlap, myImage.Height);
Bitmap im = myImage.Clone(rect, myImage.PixelFormat);
currentSlice.Read(im);
currentSlice.Page.X = i * sliceSize;
images.Add(currentSlice);
}
using (MagickImage result = images.Mosaic())
{
result.Write("test4.png");
}
}
}
i have 8 split but at the end of method test4.png is last split of my image.i need a way that each split inserted beside each other in one image.

Embed Text in Shape

I would like to embed some text into a circle in ActionScript. I have three problems: I can't get the text to center in the circle, I can't get the text to be center aligned, and I can't get the font to be applied to the text. Regarding the font, I know that it is embedded correctly, as it works on TextFields I create on the stage.
[Embed(source="DAXCOMPL.TTF", fontName="DaxCompact-Light", mimeType='application/x-font', embedAsCFF='false')]
private var MyFont:Class;
public function Bubble(...) {
var myFont:Font = new MyFont();
var myFormat:TextFormat = new TextFormat();
myFormat.size = 20;
myFormat.align = TextFormatAlign.CENTER;
myFormat.font = myFont.fontName;
var circle:Sprite = new Sprite();
var r:int = 30;
var text:TextField = new TextField();
text.text = "Hello world!";
text.wordWrap = true;
text.defaultTextFormat = myFormat;
text.autoSize = TextFieldAutoSize.LEFT;
text.x = -30;
text.y = -30;
circle.graphics.lineStyle(2, 0x000000, 1.0);
circle.graphics.drawCircle(0,0,r);
circle.graphics.endFill();
circle.addChild(text);
circle.x = 75;
circle.y = 450;
addChild(circle);
}
try to initalize the textfield this way:
var text:TextField = new TextField();
text.embedFonts = true; // use embedded font
text.defaultTextFormat = myFormat; // use this command before setting text
text.text = "Hello world!";
text.wordWrap = true;
text.autoSize = TextFieldAutoSize.LEFT;
text.x = -text.textHeight*0.5; //center the textfield after setting text
text.y = -text.textWidth*0.5;

Resources