org.eclipse.fx.ui.controls.styledtext.TextSelection Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of org.eclipse.fx.ui.controls Show documentation
Show all versions of org.eclipse.fx.ui.controls Show documentation
Custom JavaFX controls like a styled text component, ...
The newest version!
/*******************************************************************************
* Copyright (c) 2014 BestSolution.at and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tom Schindl - initial API and implementation
*******************************************************************************/
package org.eclipse.fx.ui.controls.styledtext;
import org.eclipse.jdt.annotation.NonNull;
/**
* Represent a text selection
*
* This is an experimental component provided as a preview we'll improve and
* fix problems in up coming releases
*
* @noreference
*/
public class TextSelection {
/**
* The offset
*/
public final int offset;
/**
* The length
*/
public final int length;
/**
* An empty selection
*/
@NonNull
public static final TextSelection EMPTY = new TextSelection(0,0);
/**
* Create a new selection
*
* @param offset
* the offset
* @param length
* the length
*/
public TextSelection(int offset, int length) {
this.offset = offset;
this.length = length;
}
@Override
public String toString() {
return "TextSelection [offset=" + this.offset + ", length=" + this.length + "]"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + this.length;
result = prime * result + this.offset;
return result;
}
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
TextSelection other = (TextSelection) obj;
if (this.length != other.length)
return false;
if (this.offset != other.offset)
return false;
return true;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy