I want to reposition the params docs, I had written the docs for my code earlier. Now I have rearranged the arguments of my method, I want the same to reflect in my docs written above my method. How can I do this, is there any shortcut keys? I don't want to do it manually. I have too many methods.
Earlier code and docs
/** Places the spinner on the screen on specified co-ordinates and customized drop down menu.It can be used for various option selection purpose.
* #param options The list of items the that is to be shown in the spinner's drop down menu.
* #param xCordinate The start point of the this view along x [To be given in cell number].
* #param yCordinate The start point of the this view along y [To be given in cell number].
* #param spinnerTextSize Text size of the text that is displayed on the spinner.
* #param spinnerTextColorCode The color of the text on the spinner,stored in database.[HTML color codes or Hex codes].
* #param spinnerWidth The width of the spinner.
* #param fontSize Text size of the text that is displayed on the spinner's drop down menu.
* #param fontColorCode The color of the text(stored in database) on the spinner's drop down menu.[HTML color codes or Hex codes].
* #param dropDownBackgroundColorCode The background color of the spinner's drop down menu,stored in database.[HTML color codes or Hex codes].
*/
public void spinner( int[] options, int xCoordinate, int yCoordinate, final float spinnerTextSize, int spinnerTextColorCode, int spinnerWidth, float fontSize, int fontColorCode, int dropDownBackgroundColorCode);
Repositioned arguments in the above method
public void spinner(int spinnerId, int xCordinate, int yCordinate, int spinnerWidth, final int spinnerTextSize, float fontSize, int spinnerTextColorCode, int fontColorCode, int dropDownBackgroundColorCode, int[] options)
You can do this using Eclipse's refactoring feature. Here is how:
Right-click on the method you want to change. Refactor -> Change Method Signature... or simply use Alt-Shift-C. In the menu that pops up you can change you method any way you want. In your case you will want to move parameters around. Select a parameter and use the Up and Down buttons to rearrange the list of parameters. This will also rearrange the documentation as long as the parameter names match up.
I would also like to issue some advice. You might want to look into the telescoping anti-pattern and the use of the Builder pattern to get around this pitfall.
Related
I have a style sheet set up in which I set up tags that set font size such as <size=23px>. Is it possible to somehow modify the stylesheet on runtime to change these sizes (even if I have to do it one by one)? It's for implementing a font size slider in the UI settings of the game (ideally I'd like to multiply each fontsize by a modifier).
Thank you
Edit: To clarify, I set the sizes via opening tags in the style sheets and I am looking to update these settings on runtime, NOT update the text size on the TextMeshProUGUI components!
I'm able to reference my default styleSheet directly. According to https://docs.unity3d.com/Packages/com.unity.textmeshpro#1.3/api/TMPro.TMP_StyleSheet.html "GetStyle" retrieves "the Style matching the HashCode" (or name if I give it a string parameter). Once I get the style, however, I have very limited choice: https://docs.unity3d.com/Packages/com.unity.textmeshpro#1.3/api/TMPro.TMP_Style.html?q=TMP_Style based on this, my best bet would be to query "styleOpeningDefinition".
I am able to get the opening tags via styleOpeningDefinition, and then find and replace the relevant number that denotes the size in the "<size="50px">" tag but it's a readonly property so I cant set it afterwards.
Here's the code:
TMP_Text text = GetComponent<TMP_Text>();
TMP_Style style = styleSheet.GetStyle("H1");
openingTags = style.styleOpeningDefinition;
string[] size = openingTags.Split("px><cspace=");
string _splitString = size[0].Replace("<size=", "");
float _currentSize = float.Parse(_splitString);
_currentSize *= multiplier;
string _newTags = "<size=" + _currentSize + "px>" + size[1];
style.styleOpeningDefinition = _newTags; //Property or indexer 'TMP_Style.styleOpeningDefinition' cannot be assigned to -- it is read only
style.RefreshStyle();
In Unity, you can use the UnityEngine.UI.Text component to change the font size of text elements on runtime. You can use the fontSize property of the Text component to change the font size.
using UnityEngine;
using UnityEngine.UI;
public class FontSizeModifier : MonoBehaviour
{
public Text text;
public float fontSizeModifier = 1f;
void Update()
{
text.fontSize = (int)(text.fontSize * fontSizeModifier);
}
}
This script will update the font size of the text element on every frame, multiplying the current font size by the fontSizeModifier variable.
You can use this script and attach it to the text element you want to modify, or you can create a list of texts and modify them all via a loop.
I have a JFace TableViewer with an ILazyContentProvider and a StyledCellLabelProvider for each column, which I mostly grabbed from https://wiki.eclipse.org/JFaceSnippets#Snippet006TableMultiLineCells to enable multiline rows. When I open the table, all rows have the height of the row which takes up the most space, as intended. As I scroll down the table, the row heights will change as intended if a row takes up more space. However, this does not currently work in the other direction, i.e., if I scroll so that the current rows showing take up less space, all rows still have the height of the largest row in the whole table.
Is there a way to solve this? Somehow there seems to be a memory of the content that the lazy content provider should be forgetting?
This is my measure method in the StyledCellLabelProvider:
#Override
protected void measure(Event event, Object element) {
event.width = viewer.getTable().getColumn(event.index).getWidth();
if (event.width == 0) {
return;
}
TableEntryData rowData = (TableEntryData) element;
TableCellData cellData = getCellData(rowData, event.index);
int height = event.gc.textExtent(SOME_STRING).y; // Height of a written string on one line.
int lines = cellData.getPoints().size();
event.height = height * lines;
event.gc.dispose();
}
and this is most of my ILazyContentProvider:
#Override
public void updateElement(int index) {
viewer.replace(entries.get(index), index);
}
#SuppressWarnings("unchecked") // TODO:
#Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
this.entries = (List<TableEntryData>) newInput;
}
The measure item code in the Table class (used by TableViewer) will never reduce the size of rows once it has grown bigger, so there is no way to change this.
The measure code is Table.sendMeasureItem but it can't be overridden. The code here is platform specific, but I checked both the Windows and macOS version (not sure about the Linux/GTK version).
I do have a hack to work around this, but it is platform dependent and I only have it for macOS.
#Override
public void createInitialLayout(IPageLayout layout) {
String editor = layout.getEditorArea();
layout.setEditorAreaVisible(true);
layout.addView(VIEW_EXLPORER, IPageLayout.LEFT, 0.20f, editor);
layout.getViewLayout(VIEW_EXLPORER).setCloseable(false);
IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.80f, editor);
bottom.addView(VIEW_PROGRESS);
bottom.addView(IPageLayout.ID_TASK_LIST);
bottom.addView(IPageLayout.ID_OUTLINE);
bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
//shows debug view area here
layout.addView("org.eclipse.debug.ui.DebugView", IPageLayout.LEFT, (float) 0.40, layout.getEditorArea());
}
As you see from my code i already have debug view in my custom perspective but eclipse keep promting me to switch to debug perspective when i start debugging automatically which i would like to avoid this programatically since i do now want to confuse my users.
Any way to follow?
You can try to use DebugUITools.setLaunchPerspective to either let the prompt open your custom perspective instead of the default one or disable the prompt at all.
From its Javadoc:
/**
* Sets the perspective to switch to when a configuration of the given type
* is launched in the given mode. <code>PERSPECTIVE_NONE</code> indicates no
* perspective switch should take place. <code>PERSPECTIVE_DEFAULT</code> indicates
* a default perspective switch should take place, as defined by the associated
* launch tab group extension.
*
* In 3.3 this method is equivalent to calling <code>setLaunchPerspective(ILaunchConfigurationType type, Set modes, ILaunchDelegate delegate, String perspectiveid)</code>,
* with the parameter 'mode' used in the set modes, and null passed as the delegate
*
* #param type launch configuration type
* #param mode launch mode identifier
* #param perspective identifier, <code>PERSPECTIVE_NONE</code>, or
* <code>PERSPECTIVE_DEFAULT</code>
* #since 3.0
*/
Is it there a property to arrange menu items horizontally AndEngine?
The default layout is vertical, do you know a way to set it horizontal?
There isn't a built it functionality that would arrange menu items horizontally, but check the MenuSceneAnimator class, especially getMenuItemX and getMenuItemY methods. It should be pretty easy to implement your own positioning that will suit your needs.
This is the solution I came up with, I know it can be optimized, but it works.
/**
* Sets menu items layout to horizontal
* #author Lucas Massuh
* #version 1.0
* #since 2015-05-28
* #return returns the "horizontalised" menu, just in case.
* #param menu This should be the menu scene containing all the Menu Items to be set horizontal
* #param padding This is the horizontal padding between each Menu Item
*/ private static MenuScene setMenuLayoutToHorizontal(MenuScene menu, int padding){
if (menu.getChildCount()<=1) return menu;
// Starts at 1 since child[0] position won't be changed
for(int i=1; i<menu.getChildCount();i++){
menu.getChildByIndex(i).setPosition(
//it can be optimized by pre-calculating item's width if they are all equal
menu.getChildByIndex(i-1).getX()+menu.getChildByIndex(i).getWidth()+padding,
menu.getChildByIndex(0).getY());
}
return menu;
}
I try to build a part of an eclipse pref page which contains a table and add/remove-buttons. I have found some example code but I don't understand the following thing:
The method
protected void adjustForNumColumns(int numColumns) {
((GridData)top.getLayoutData()).horizontalSpan = numColumns;
}
sets the horizontal span for the parent (top) composite to the number of columns.
And the method
protected void doFillIntoGrid(Composite parent, int numColumns) {
top = parent;
// set layout
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = numColumns;
top.setLayoutData(gd); ... }
sets the layout with the horizontal span set to the number of columns.
Which method is used when and why is the number of columns somehow applied twice to a grid data object? It might be a pretty stupid question but I just started with the whole thing... Can anybody explain to me how it works? (Or even refer to a nice webpage where I can find an explanation)
You might find this article on SWT layouts useful - http://www.eclipse.org/articles/article.php?file=Article-Understanding-Layouts/index.html